public void Awake()
		{
			encoder = new Encoder();
			decoder = new Decoder();
			parser = new Parser();
			handlers = new Dictionary<string, List<Action<SocketIOEvent>>>();
			ackList = new List<Ack>();
			sid = null;
			packetId = 0;

			ws = new WebSocket(url);
			ws.OnOpen += OnOpen;
			ws.OnMessage += OnMessage;
			ws.OnError += OnError;
			ws.OnClose += OnClose;
			wsConnected = false;

			eventQueueLock = new object();
			eventQueue = new Queue<SocketIOEvent>();

			ackQueueLock = new object();
			ackQueue = new Queue<Packet>();

			connected = false;

			#if SOCKET_IO_DEBUG
			if(debugMethod == null) { debugMethod = Debug.Log; };
			#endif
		}
		public void Init()
		{
			ws = new WebSocket(url);
			encoder = new Encoder();
			decoder = new Decoder();
			parser = new Parser();
			handlers = new Dictionary<string, List<Action<SocketIOEvent>>>();
			acknowledges = new Dictionary<int, Action<JSONObject>>();
			sid = null;
			packetId = 1;

			ws.OnOpen += OnOpen;
			ws.OnMessage += OnMessage;
			ws.OnError += OnError;
			ws.OnClose += OnClose;

			// TODO: start acknowledges garbage collection coroutine in X seconds
		}
        void Awake()
        {
            _encoder = new Encoder();
            _decoder = new Decoder();
            _parser = new Parser();
            _handlers = new Dictionary<string, List<Action<SocketIOEvent>>>();
            _ackList = new List<Ack>();
            _packetId = 0;

            _eventQueueLock = new object();
            _eventQueue = new Queue<SocketIOEvent>();

            _ackQueueLock = new object();
            _ackQueue = new Queue<Packet>();

            #if SOCKET_IO_DEBUG
            if (_debugMethod == null) { _debugMethod = Debug.Log; };
            #endif
        }
		public void Awake()
		{
			//Makes this object stay throughout the entire scene
			if (dontDestroyOnLoad) {
				DontDestroyOnLoad (transform.gameObject);
			}

			encoder = new Encoder();
			decoder = new Decoder();
			parser = new Parser();
			handlers = new Dictionary<string, List<Action<SocketIOEvent>>>();
			ackList = new List<Ack>();
			sid = null;
			packetId = 0;

			ws = new WebSocket(url);
			ws.OnOpen += OnOpen;
			ws.OnMessage += OnMessage;
			ws.OnError += OnError;
			ws.OnClose += OnClose;
			wsConnected = false;

			eventQueueLock = new object();
			eventQueue = new Queue<SocketIOEvent>();

			ackQueueLock = new object();
			ackQueue = new Queue<Packet>();

			connected = false;

			#if SOCKET_IO_DEBUG
			if(debugMethod == null) { debugMethod = Debug.Log; };
			#endif
		}
Exemple #5
0
        public void init(string hostname, string port)
        {
            encoder = new Encoder();
            decoder = new Decoder();
            parser = new Parser();
            handlers = new Dictionary<string, List<Action<SocketIOEvent>>>();
            ackList = new List<Ack>();
            sid = null;
            packetId = 0;
            url = "ws://" + hostname + ":" + port +"/socket.io/?EIO=4&transport=websocket";
            ws = new WebSocket(url);
            ws.OnOpen += OnOpen;
            ws.OnMessage += OnMessage;
            ws.OnError += OnError;
            ws.OnClose += OnClose;
            wsConnected = false;

            eventQueueLock = new object();
            eventQueue = new Queue<SocketIOEvent>();

            ackQueueLock = new object();
            ackQueue = new Queue<Packet>();

            connected = false;

            print ("set up connection " + url);
        }