示例#1
0
        public static void Test(string host, int port)
        {
            var server = new DotNettyServer(host, port);

            server.OnRecieveLoginRequest   += Server_OnRecieveLoginRequest;
            server.OnRecieveServiceRequest += Server_OnRecieveRequest;
            server.StartAsync().ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    System.Console.WriteLine(task.Exception.InnerException.Message);
                    return;
                }
                System.Console.WriteLine($"Server listen port {port}");
            });

            System.Console.ReadLine();

            server.CloseAsync().ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    System.Console.WriteLine(task.Exception.InnerException.Message);
                    return;
                }
                System.Console.WriteLine("Server closed");
            });
        }
示例#2
0
        static void Main(string[] args)
        {
            DotNettyServer _netty = new DotNettyServer(10228);

            _netty.OnRecieveServiceRequest += _netty_OnRecieveServiceRequest;
            _netty.StartAsync();

            Console.ReadLine();
        }