Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("연결복구테스트방법 : '/k'명령으로 강제연결종료시 일정시간 이후 자동연결복구됨(연결죽인상태의 채팅내용모두 연결복구시점에 복구되는것을 확인 가능) 또한 'f'명령으로 현재 상태에서 즉각적인 연결복구를 테스트해볼수도 있습니다\n");

            CClient Client = new CClient();

            Client.m_Core.Connect(
                "127.0.0.1",
                20000,
                0,     // protocol version
                50,    // udp recve port : if 0 = disable
                false, // mobile optimize option
                true   //false       // enable auto connection recovery mode
                );

            Console.Write("> ");

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

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

                    case "/c":
                        Console.WriteLine("reconnect try...");
                        if (Client.m_Core.ReConnect() == false)
                        {
                            Console.WriteLine("reconnect fail. check connection not disconnect or recovery mode");
                        }
                        break;

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

                    case "/h":
                        DisplayHelpCommand();
                        break;

                    case "/f":
                        Client.m_Core.FastRecovery();     // 즉시 연결복구 처리하기
                        break;

                    case "/k":
                        Client.m_Core.ForceLeave();       // 일방적인 서버와의 연결종료
                        break;

                    default:
                        // packet send test
                        RemoteClass.CUserClass    _testClass = new RemoteClass.CUserClass();
                        Dictionary <Int32, Int32> _testDic   = new Dictionary <Int32, Int32>();
                        _testDic.Add(1212345, 1230);

                        Client.proxy.request_message(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Encrypt, _testClass, _testDic, ret.Result);

                        Client.stub.reponse_message = (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);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            CClient Client = new CClient();

            Client.m_Core.Connect(
                "127.0.0.1",
                20000,
                0,          // protocol version
                50,         // udp recve port : if 0 = disable
                false,      // mobile optimize option
                true//false       // enable auto connection recovery mode
                );

            Console.Write("> ");

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

                        case "/c":
                            Console.WriteLine("reconnect try...");
                            if (Client.m_Core.ReConnect() == false)
                            {
                                Console.WriteLine("reconnect fail. check connection not disconnect or recovery mode");
                            }
                            break;

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

                        case "/h":
                            DisplayHelpCommand();
                            break;

                        case "/f":
                            Client.m_Core.FastRecovery(); // 즉시 연결복구 처리하기
                            break;

                        case "/k":
                            Client.m_Core.ForceLeave();   // 일방적인 서버와의 연결종료
                            break;

                        default:
                            // packet send test
                            RemoteClass.CUserClass _testClass = new RemoteClass.CUserClass();
                            Dictionary<Int32, Int32> _testDic = new Dictionary<Int32, Int32>();
                            _testDic.Add(1212345, 1230);

                            Client.proxy.request_message(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Encrypt, _testClass, _testDic, ret.Result);

                            Client.stub.reponse_message = (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);
        }