Ejemplo n.º 1
0
        public static void RegisterLiveChat(int id)
        {
            if (chatSockets.ContainsKey(id))
            {
                return;
            }


            var socket = IO.Socket(VMT_URL);

            chatSockets[id] = socket;

            socket.On(Socket.EVENT_CONNECT, () =>
            {
                socket.Emit("observeRoom", "room" + id.ToString());
                Debug.WriteLine(String.Format("RegisterLiveChat({0}) | User Connected!", id));
            });
            socket.On(Socket.EVENT_DISCONNECT, () =>
            {
                socket.Emit("user disconnected");
                Debug.WriteLine(String.Format("RegisterLiveChat({0}) | User Disconnected!", id));
            });

            socket.On("showChat", (data) =>
            {
                Debug.WriteLine(String.Format("RegisterLiveChat({0}) | New Msg!", id));
                string results = data.ToString();
                //ctrl.ResetState();
                ctrl.HandleLiveMessage(id, results);
            });
        }