Exemplo n.º 1
0
        static void Main(string[] args)
        {
            CClient Client = new CClient();

            Client.m_Core.Connect("127.0.0.1", 20000, 0);
            Console.Write("> ");

            var  ret         = ReadLineAsync();
            bool run_program = true;

            while (run_program)
            {
                if (ret.IsCompleted)
                {
                    switch (ret.Result)
                    {
                    case "/q":
                        Client.m_Core.Leave();
                        break;

                    case "/exit":
                        run_program = false;
                        break;

                    case "/h":
                        Console.WriteLine("/Cmd:  h(Help) q(Quit) exit(ProgramExit)");
                        break;

                    default:
                        // 보낼 패킷 데이터 준비
                        RemoteClass.CUserClass    _testClass = new RemoteClass.CUserClass();
                        Dictionary <Int32, Int32> _testDic   = new Dictionary <Int32, Int32>();
                        _testDic.Add(1212345, 1230);

                        // 패킷 보내고
                        Client.proxy.request_Echo(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Encrypt, _testClass, _testDic, ret.Result);

                        // 패킷 받을때 처리
                        Client.stub.reponse_Echo = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary <Int32, Int32> dic_test, string msg) =>
                        {
                            Console.WriteLine(string.Format("recv : {0}", msg));
                            return(true);
                        };
                        break;
                    }

                    if (run_program)
                    {
                        ret = ReadLineAsync();
                    }
                }

                Client.m_Core.NetLoop();
                System.Threading.Thread.Sleep(1);
            }

            Client.m_Core.Destroy();
            System.Threading.Thread.Sleep(1000 * 2);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CClient Client = new CClient();

            Client.m_Core.Connect("127.0.0.1", 20000, 0);
            Console.Write("> ");

            var ret = ReadLineAsync();
            bool run_program = true;
            while (run_program)
            {
                if (ret.IsCompleted)
                {
                    switch (ret.Result)
                    {
                        case "/q":
                            Client.m_Core.Leave();
                            break;

                        case "/exit":
                            run_program = false;
                            break;

                        case "/h":
                            Console.WriteLine("/Cmd:  h(Help) q(Quit) exit(ProgramExit)");
                            break;

                        default:
                            // 보낼 패킷 데이터 준비
                            RemoteClass.CUserClass _testClass = new RemoteClass.CUserClass();
                            Dictionary<Int32, Int32> _testDic = new Dictionary<Int32, Int32>();
                            _testDic.Add(1212345, 1230);

                            // 패킷 보내고
                            Client.proxy.request_Echo(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Encrypt, _testClass, _testDic, ret.Result);

                            // 패킷 받을때 처리
                            Client.stub.reponse_Echo = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary<Int32, Int32> dic_test, string msg) =>
                            {
                                Console.WriteLine(string.Format("recv : {0}", msg));
                                return true;
                            };
                            break;
                    }

                    if (run_program)
                        ret = ReadLineAsync();
                }

                Client.m_Core.NetLoop();
                System.Threading.Thread.Sleep(1);
            }

            Client.m_Core.Destroy();
            System.Threading.Thread.Sleep(1000 * 2);
        }