Beispiel #1
0
        private void Form1_Closed(object sender, EventArgs e)
        {
            /// 移除事件通知
            WebSocketServer.NewConnEvent   -= WebSocketEvent.NewConnEvent;
            WebSocketServer.RecMsgEvent    -= WebSocketEvent.RecMsgEvent;
            WebSocketServer.RecTextEvent   -= WebSocketEvent.RecTextEvent;
            WebSocketServer.ConnCloseEvent -= WebSocketEvent.ConnCloseEvent;
            /// 释放对象
            if (null != WebSocketServer)
            {
                WebSocketServer.Close();
                WebSocketServer = null;
            }

            WebSocketServer = null;
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            WebSocketServer = new SocketProxyClass();
            if (null == WebSocketServer)
            {
                return;
            }
            WebSocketEvent = new WebSocketEventSink();
            if (null == WebSocketEvent)
            {
                return;
            }
            WebSocketEvent.SetForm(this);
            ushort nPort       = ushort.Parse(m_Para["PORT"]);
            ushort nListenPort = WebSocketServer.Listen(nPort, m_Para["SID"], m_Para["AI"]);

            /// 建立事件通知
            WebSocketServer.NewConnEvent   += WebSocketEvent.NewConnEvent;
            WebSocketServer.RecMsgEvent    += WebSocketEvent.RecMsgEvent;
            WebSocketServer.RecTextEvent   += WebSocketEvent.RecTextEvent;
            WebSocketServer.ConnCloseEvent += WebSocketEvent.ConnCloseEvent;
        }