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"); }); }
static void Main(string[] args) { DotNettyServer _netty = new DotNettyServer(10228); _netty.OnRecieveServiceRequest += _netty_OnRecieveServiceRequest; _netty.StartAsync(); Console.ReadLine(); }