Exemplo n.º 1
1
        private JsonWebSocket CreateWebSocket(ServerConfig config)
        {
            var websocket = new JsonWebSocket(string.Format("ws://{0}:{1}/", config.Host, config.Port), "ServerManager");
#if SILVERLIGHT
            websocket.Opened += new EventHandler(CreateAsyncOperation<object, EventArgs>(m_WebSocket_Opened));
            websocket.Error += new EventHandler<ClientEngine.ErrorEventArgs>(CreateAsyncOperation<object, ClientEngine.ErrorEventArgs>(m_WebSocket_Error));
            websocket.Closed += new EventHandler(CreateAsyncOperation<object, EventArgs>(m_WebSocket_Closed));
            websocket.On<ServerInfo>(CommandName.UPDATE, CreateAsyncOperation<ServerInfo>(OnServerUpdated));
#else
            websocket.Opened += new EventHandler(m_WebSocket_Opened);
            websocket.Error += new EventHandler<ClientEngine.ErrorEventArgs>(m_WebSocket_Error);
            websocket.Closed += new EventHandler(m_WebSocket_Closed);
            websocket.On<ServerInfo>(CommandName.UPDATE, OnServerUpdated);
#endif

            websocket.Open();
            State = ConnectionState.Connecting;
            m_ErrorPopped = false;

            foreach (var instance in Instances)
            {
                instance.State = InstanceState.Connecting;
            }

            return websocket;
        }
Exemplo n.º 2
0
 static JsonWebSocket CreateWebSocket()
 {
     var websocket = new JsonWebSocket("ws://127.0.0.1:2011/");
     
     websocket.On<string>("ECHO", HandleEchoResponse);
     websocket.Closed += new EventHandler(websocket_Closed);
     websocket.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocket_Error);
     websocket.Opened += new EventHandler(websocket_Opened);
     websocket.Open();
     return websocket;
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var websocket = new JsonWebSocket("ws://127.0.0.1:2011/");

            websocket.On<string>("ECHO", HandleEchoResponse);
            websocket.Closed += new EventHandler(websocket_Closed);
            websocket.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocket_Error);
            websocket.Opened += new EventHandler(websocket_Opened);
            websocket.Open();

            m_PrintTimer = new Timer(OnPrintTimerCallback, null, 1000 * 5, 1000 * 5);

            while (!Console.ReadLine().ToLower().Equals("q"))
                continue;

            m_Stopped = true;
            m_PrintTimer.Change(Timeout.Infinite, Timeout.Infinite);

            m_ClosedEvent.WaitOne();

            Console.WriteLine("Quit");
            Console.ReadLine();
        }