예제 #1
0
        private void button1_Click(object sender1, EventArgs e1)
        {
            try
            {
                MCserver = new WebSocketServer(MCServerUrl);
                MCserver.Start(socket =>
                {
                    socket.OnOpen = () =>
                    {
                        host.OnOpenMCWebSocket(socket);
                    };
                    socket.OnClose = () =>
                    {
                        host.OnCloseMCWebSocket(socket);
                    };
                    socket.OnMessage = message =>
                    {
                        host.OnMCMessage(message, socket);
                    };
                });


                FMserver = new WebSocketServer(FMServerUrl);
                FMserver.Start(socket =>
                {
                    socket.OnOpen = () =>
                    {
                        FuncModuleManager.addClient(socket);
                    };
                    socket.OnClose = () =>
                    {
                        FuncModuleManager.removeClient(socket);
                    };
                    socket.OnMessage = message =>
                    {
                        Debug.WriteLine("*****  FM Client Message  => " + message);
                        host.FMSend(message);
                    };
                    socket.OnError = (error) =>
                    {
                        Debug.WriteLine("OnError => " + error.Data);
                        FuncModuleManager.removeClient(socket);
                    };
                });

                //this.initial_udp_server(Program.inputPort);
                //检查设备状态(Program.getRemoteIPEndPoint(), 3000);

                this.button2.Enabled = true;
                this.button1.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }