package com.kuckovsky.richard.home;

import android.util.Log;

import java.net.URISyntaxException;

import io.socket.client.IO;
import io.socket.client.Socket;
import io.socket.emitter.Emitter;

/**
 * Created by richard on 4.6.17.
 */

public class SocketIO {

    private static SocketIO instance;

    static {
        instance = new SocketIO();
    }
    private SocketIO() {
    }

    public Socket mSocket;
    {
        try {
            mSocket = IO.socket("http://192.168.0.100:90");
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    public void connect() {
        mSocket.connect();
    }

    public void onConnect() {
        mSocket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
            @Override
            public void call (Object...args) {
                Log.i("OK", "Som prihlaseny");
            }
        });
    }


    public static SocketIO getInstance() {
        return SocketIO.instance;
    }

}
