// Path: localnet/src/main/java/dev/jokr/localnet/LocalSession.java
// public abstract class LocalSession {
// 
//     /*
//      *  Class that represent session of messaging between devices.
//      *  All session events (like sending or receiving a message) and logic connected to them
//      *  should be implemented here, not in Activity class or others.
//      *
//      *
//      *  Code here will be executed in service.
//      *
//      */
// 
//     // Communicator for interacting with running service
//     private Communicator communicator;
// 
//     public LocalSession() {}
// 
//     /*
//      * This method sends session message to specified recipient. Recipient will
//      * receive message in their LocalClient instance.
//      */
//     public void sendMessage(long recipientId, Payload<?> payload) {
//         communicator.sendMessage(recipientId, payload);
//     }
// 
//     /*
//      * This method is used to send message to all clients connected.
//      */
//     public void sendBroadcastMessage(Payload<?> payload) {
//         communicator.sendBroadcastMessage(payload);
//     }
// 
//     /*
//      * Logic in this class is executed in service. If you want show some data on the UI, you can use
//      * this method to send data to your Activity/Fragment or other classes.
//      */
//     public void sendUiEvent(Payload<?> payload) {
//         communicator.sendUiEvent(payload);
//     }
// 
//     /*
//      * This method is used for setting communicator with running service. Called before onCreate.
//      */
//     public void preCreateInit(Communicator communicator) {
//         this.communicator = communicator;
//     }
// 
//     /*
//      * This is where you should start your session logic. You receive bundle (if you set any from
//      * Local Server) and connected clients.
//      */
//     public abstract void onCreate(Bundle bundle, ConnectedClients connectedClients);
// 
//     /*
//      *  In this method you will receive message sent from clients.
//      */
//     public abstract void onReceiveMessage(long recipientId, Payload payload);
// 
//     /*
//      *  You can send events from your UI (activities, fragments...) to LocalSession at any time.
//      *  You will receive data in this method.
//      */
//     public abstract void onEvent(Payload<?> payload);
// 
// }
// 
// Path: localnet/src/main/java/dev/jokr/localnet/models/ConnectedClients.java
// public class ConnectedClients {
// 
//     private HashMap<Long, RegisterMessage> registeredClients;
// 
//     public ConnectedClients(HashMap<Long, RegisterMessage> registeredClients) {
//         this.registeredClients = registeredClients;
//     }
// 
//     public Payload<?> getPayload(int clientId) {
//         if (registeredClients.containsKey(clientId))
//             return registeredClients.get(clientId).getPayload();
//         else
//             return null;
//     }
// 
//     public Set<Long> getAllClientsIds() {
//         return registeredClients.keySet();
//     }
// 
//     public int getClientsSize() {
//         return registeredClients.size();
//     }
// 
// }
// 
// Path: localnet/src/main/java/dev/jokr/localnet/models/Payload.java
// public class Payload<T> implements Serializable {
// 
//     private T payload;
// 
//     public Payload(T payload) {
//         this.payload = payload;
//     }
// 
//     public T getPayload() {
//         return payload;
//     }
// 
// 
// }
// 
// Path: localnet/src/main/java/dev/jokr/localnet/models/SessionMessage.java
// public class SessionMessage implements Serializable {
// 
//     public static final int NONE = 0;
//     public static final int START = 1;
//     public static final int END = 2;
// 
//     private Payload<?> payload;
//     private int signal;
// 
// 
//     public SessionMessage(Payload<?> payload) {
//         this.payload = payload;
//         this.signal = NONE;
//     }
// 
//     public SessionMessage(Payload<?> payload, int signal) {
//         this.payload = payload;
//         this.signal = signal;
//     }
// 
//     public int getSignal() {
//         return signal;
//     }
// 
//     public Payload<?> getPayload() {
//         return payload;
//     }
// }


import android.os.Bundle;
import android.util.Log;
import dev.jokr.localnet.LocalSession;
import dev.jokr.localnet.models.ConnectedClients;
import dev.jokr.localnet.models.Payload;
import dev.jokr.localnet.models.SessionMessage;
package dev.jokr.localnetworkapp;



/**
 * Created by JoKr on 8/31/2016.
 */
public class GameSession extends LocalSession {

    /*
     *  You extend LocalSession and put all your logic here. Check LocalSession class
     *  in library for more info.
     */

    @Override
    public void onCreate(Bundle bundle, ConnectedClients connectedClients){
        Log.d("USER", "SESSION: onCreate");
//        long id = (long) connectedClients.getAllClientsIds().toArray()[0];
//        sendMessage(id, new Payload<MyMessage>(new ));
    }

    @Override
// Path: localnet/src/main/java/dev/jokr/localnet/LocalSession.java
// public abstract class LocalSession {
// 
//     /*
//      *  Class that represent session of messaging between devices.
//      *  All session events (like sending or receiving a message) and logic connected to them
//      *  should be implemented here, not in Activity class or others.
//      *
//      *
//      *  Code here will be executed in service.
//      *
//      */
// 
//     // Communicator for interacting with running service
//     private Communicator communicator;
// 
//     public LocalSession() {}
// 
//     /*
//      * This method sends session message to specified recipient. Recipient will
//      * receive message in their LocalClient instance.
//      */
//     public void sendMessage(long recipientId, Payload<?> payload) {
//         communicator.sendMessage(recipientId, payload);
//     }
// 
//     /*
//      * This method is used to send message to all clients connected.
//      */
//     public void sendBroadcastMessage(Payload<?> payload) {
//         communicator.sendBroadcastMessage(payload);
//     }
// 
//     /*
//      * Logic in this class is executed in service. If you want show some data on the UI, you can use
//      * this method to send data to your Activity/Fragment or other classes.
//      */
//     public void sendUiEvent(Payload<?> payload) {
//         communicator.sendUiEvent(payload);
//     }
// 
//     /*
//      * This method is used for setting communicator with running service. Called before onCreate.
//      */
//     public void preCreateInit(Communicator communicator) {
//         this.communicator = communicator;
//     }
// 
//     /*
//      * This is where you should start your session logic. You receive bundle (if you set any from
//      * Local Server) and connected clients.
//      */
//     public abstract void onCreate(Bundle bundle, ConnectedClients connectedClients);
// 
//     /*
//      *  In this method you will receive message sent from clients.
//      */
//     public abstract void onReceiveMessage(long recipientId, Payload payload);
// 
//     /*
//      *  You can send events from your UI (activities, fragments...) to LocalSession at any time.
//      *  You will receive data in this method.
//      */
//     public abstract void onEvent(Payload<?> payload);
// 
// }
// 
// Path: localnet/src/main/java/dev/jokr/localnet/models/ConnectedClients.java
// public class ConnectedClients {
// 
//     private HashMap<Long, RegisterMessage> registeredClients;
// 
//     public ConnectedClients(HashMap<Long, RegisterMessage> registeredClients) {
//         this.registeredClients = registeredClients;
//     }
// 
//     public Payload<?> getPayload(int clientId) {
//         if (registeredClients.containsKey(clientId))
//             return registeredClients.get(clientId).getPayload();
//         else
//             return null;
//     }
// 
//     public Set<Long> getAllClientsIds() {
//         return registeredClients.keySet();
//     }
// 
//     public int getClientsSize() {
//         return registeredClients.size();
//     }
// 
// }
// 
// Path: localnet/src/main/java/dev/jokr/localnet/models/Payload.java
// public class Payload<T> implements Serializable {
// 
//     private T payload;
// 
//     public Payload(T payload) {
//         this.payload = payload;
//     }
// 
//     public T getPayload() {
//         return payload;
//     }
// 
// 
// }
// 
// Path: localnet/src/main/java/dev/jokr/localnet/models/SessionMessage.java
// public class SessionMessage implements Serializable {
// 
//     public static final int NONE = 0;
//     public static final int START = 1;
//     public static final int END = 2;
// 
//     private Payload<?> payload;
//     private int signal;
// 
// 
//     public SessionMessage(Payload<?> payload) {
//         this.payload = payload;
//         this.signal = NONE;
//     }
// 
//     public SessionMessage(Payload<?> payload, int signal) {
//         this.payload = payload;
//         this.signal = signal;
//     }
// 
//     public int getSignal() {
//         return signal;
//     }
// 
//     public Payload<?> getPayload() {
//         return payload;
//     }
// }


// Path: app/src/main/java/dev/jokr/localnetworkapp/GameSession.java
import android.os.Bundle;
import android.util.Log;
import dev.jokr.localnet.LocalSession;
import dev.jokr.localnet.models.ConnectedClients;
import dev.jokr.localnet.models.Payload;
import dev.jokr.localnet.models.SessionMessage;

package dev.jokr.localnetworkapp;



/**
 * Created by JoKr on 8/31/2016.
 */
public class GameSession extends LocalSession {

    /*
     *  You extend LocalSession and put all your logic here. Check LocalSession class
     *  in library for more info.
     */

    @Override
    public void onCreate(Bundle bundle, ConnectedClients connectedClients){
        Log.d("USER", "SESSION: onCreate");
//        long id = (long) connectedClients.getAllClientsIds().toArray()[0];
//        sendMessage(id, new Payload<MyMessage>(new ));
    }

    @Override
    public void onReceiveMessage(long recipientId, Payload payload) {