예제 #1
0
        public Form1()
        {
            InitializeComponent();

            m_socket         = new SocketIOSocket();
            m_socket.Debug   = Console.WriteLine;
            m_socket.Info    = Console.WriteLine;
            m_socket.Warning = Console.WriteLine;
            m_socket.Error   = Console.WriteLine;

            m_socket.On("open", Console.WriteLine);
            m_socket.On("message", Console.WriteLine);
            m_socket.On("close", Console.WriteLine);
            m_socket.On("error", Console.WriteLine);

            m_socket.Start();

            m_ping = new PingPong(m_socket);

            m_timer          = new Timer();
            m_timer.Interval = 33;
            m_timer.Tick    += (o, e) =>
            {
                m_socket.Update();
            };
            m_timer.Start();
        }
예제 #2
0
        private void OnConnection(EngineIOSocket EngineIOSocket)
        {
            SocketIOSocket Socket = new SocketIOSocket(EngineIOSocket, this);

            SimpleMutex.Lock(ClientMutex, () =>
            {
                _Clients.Add(Socket);

                Socket.On(SocketIOEvent.DISCONNECT, () =>
                {
                    SimpleMutex.Lock(ClientMutex, () =>
                    {
                        _Clients.Remove(Socket);
                    });
                });

                Socket.Emit(SocketIOPacket.CreateConnectionPacket());
                ConnectionHandlerManager.Emit(SocketIOEvent.CONNECTION, Socket);
            });
        }