Ejemplo n.º 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");
            });
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            DotNettyServer _netty = new DotNettyServer(10228);

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

            Console.ReadLine();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///server 启动端口连接
        /// </summary>
        /// <param name="port"></param>
        public static async void Start(string config)
        {
            MConfiguration.Bind <Config.MConfig>(config);
            RpcConatiner.Initialize();
            DotNettyServer server = new DotNettyServer();
            await server.Listen(Config.MConfig.Port);

            System.Console.WriteLine("开始监听{0}:{1}", Config.MConfig.Host, Config.MConfig.Port);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///server 启动端口连接
        /// </summary>
        /// <param name="port"></param>
        public async void Start(int port)
        {
            RpcConatiner.Initialize();
            DotNettyServer server = new DotNettyServer();
            await server.Listen(port);

            await Task.Factory.StartNew(async() =>
            {
                await server.Listen(port);
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        ///server 启动端口连接
        /// </summary>
        /// <param name="port"></param>
        public async void Start(int port)
        {
            RpcConatiner.Initialize();
            //SyncTcpServer server = new SyncTcpServer();
            DotNettyServer server = new DotNettyServer();
            await server.Listen(port);

            // server.Handle += new RpcDefaultRequestHandler().Handle;
            await Task.Factory.StartNew(async() =>
            {
                await server.Listen(port);
            });
        }