// 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.Handler;
import android.os.Looper;
import android.util.Log;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import dev.jokr.localnet.models.SessionMessage;
package dev.jokr.localnet;




/**
 * Created by JoKr on 8/29/2016.
 */
class ClientSocketThread implements Runnable {

    private  ServiceCallback callback;

    public ClientSocketThread(ServiceCallback callback) {
        this.callback = callback;
    }

    @Override
    public void run() {
       ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(0);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d("USER", "Listening on " + serverSocket.getLocalPort());
        notifySocketInitialized(serverSocket.getLocalPort());

        while(true) {
            try {
                Socket socket = serverSocket.accept();
                ObjectInputStream objectInputStream = new ObjectInputStream(socket.getInputStream());
// 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: localnet/src/main/java/dev/jokr/localnet/ClientSocketThread.java
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import dev.jokr.localnet.models.SessionMessage;

package dev.jokr.localnet;




/**
 * Created by JoKr on 8/29/2016.
 */
class ClientSocketThread implements Runnable {

    private  ServiceCallback callback;

    public ClientSocketThread(ServiceCallback callback) {
        this.callback = callback;
    }

    @Override
    public void run() {
       ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(0);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Log.d("USER", "Listening on " + serverSocket.getLocalPort());
        notifySocketInitialized(serverSocket.getLocalPort());

        while(true) {
            try {
                Socket socket = serverSocket.accept();
                ObjectInputStream objectInputStream = new ObjectInputStream(socket.getInputStream());
                SessionMessage sessionMessage = (SessionMessage) objectInputStream.readObject();