Пример #1
0
        static void Main(string[] args)
        {
            LoginListener.instance.AddListener(delegate(Socket cfd, GameProto.Login login)
            {
                Console.WriteLine(String.Format("Check Account = {0}", login.Account));
                ServerNetManager.Send(cfd, (Int16)ProtocType.Login, login);
                ServerNetManager.Send(cfd, (Int16)ProtocType.LoginRes, new GameProto.LoginRes
                {
                    IsMatch = true,
                });
            });

            ServerNetManager.Bind("127.0.0.1", 8888);

            ConsoleAsync console = new ConsoleAsync();

            bool isShutdown = false;

            while (!isShutdown)
            {
                string cmd = console.TryReadLine();
                if (cmd != null)
                {
                    if (cmd == "exit")
                    {
                        isShutdown = true;
                    }
                }

                ServerNetManager.Update();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            LoginListener.instance.AddListener(delegate(GameProto.Login msg)
            {
                Console.WriteLine(String.Format("account = {0}", msg.Account));
                Console.WriteLine(String.Format("password = {0}", msg.Password));
            });

            LoginResListener.instance.AddListener(delegate(GameProto.LoginRes loginRes)
            {
                if (loginRes.IsMatch)
                {
                    Console.WriteLine("Login successfully.");
                }
                else
                {
                    Console.WriteLine("Login failed");
                }
            });

            Console.WriteLine("client is running...");
            ConsoleAsync console = new ConsoleAsync();

            while (!isShutdown)
            {
                string cmd = console.TryReadLine();
                if (cmd != null)
                {
                    ParseCommand(cmd);
                }

                NetManager.Update();
            }
        }