Ejemplo n.º 1
0
        public static void StartWS(Action connect_ready)
        {
            var socket = IO.Socket(WSManager.live_ws_url);

            Trace.WriteLine("--Socket INIT--");
            socket.On(Socket.EVENT_CONNECT, () =>
            {
                Trace.WriteLine("--Socket Connected--");
                string regMessage = Newtonsoft.Json.JsonConvert.SerializeObject(new { compId = ProfileManager.compId, token = ClanREST.UserToken });
                socket.Emit("openSession", regMessage);
            });

            socket.On(String.Format("/topic/chat/user/{0}", ProfileManager.userID), WSManager.OnMessage);
            socket.On(String.Format("/manage/{0}", ProfileManager.compId), WSManager.OnCompManage);
            socket.On(String.Format("/session/{0}", ProfileManager.compId), (_) => {
                Trace.WriteLine("---- SESSION CREATED ----");
                connect_ready();
            });
            socket.On(String.Format("/errorHandler/{0}", ProfileManager.compId), (data) => WSManager.OnError(data));

            socket.Connect();
            _socket = socket;
        }
Ejemplo n.º 2
0
 public void LogOut()
 {
     user_token = null;
     WSManager.CloseWS();
 }