コード例 #1
0
        static async void StartServer()
        {
            // _Server.Start();
            await _Server.StartAsync();

            Console.WriteLine("Server is listening: " + _Server.IsListening);
        }
コード例 #2
0
        private async void Start_Click(object sender, RoutedEventArgs e)
        {
            if (this.server != null && this.server.IsListening)
            {
                this.server.Stop();
            }

            var part = Address.Text.Split(":");
            var ip   = part[0];
            var port = int.Parse(part[1]);

            WatsonWsServer server = new WatsonWsServer(ip, port, false);

            server.ClientConnected    += ClientConnected;
            server.ClientDisconnected += ClientDisconnected;
            server.MessageReceived    += MessageReceived;
            await server.StartAsync();

            if (server.IsListening)
            {
                this.server   = server;
                Content.Text += $"Server Start\n\n";
            }
            else
            {
                Content.Text += $"Can not start the server\n\n";
            }
        }