コード例 #1
0
ファイル: NetMgr.cs プロジェクト: isoundy000/shmj3d
    public void Login(string account, string token)
    {
        int port = 5005;

        mAccount = account;
        mToken   = token;

        Debug.Log("Login");

        pc.initClient(mServer, port, ret => {
            if (!ret)
            {
                Debug.Log("Login initClient fail");
                GameAlert.Show("连接服务器失败,请检查网络");
                return;
            }

            pc.connect(null, data => {
                JsonObject msg = new JsonObject();
                msg ["uid"]    = account;

                pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
            });
        });
    }
コード例 #2
0
 /// <summary>
 /// connect to server and response
 /// </summary>
 /// <param name="ip"></param>
 /// <param name="port"></param>
 /// <param name="user">handshake msg for connect</param>
 /// <param name="action">default request callback</param>
 public void Connect(string ip, int port, JsonObject user, Action <JsonObject> action)
 {
     if (m_Conn != null)
     {
         Debug.Log("the network has been connected!");
         return;
     }
     Debug.Log("connect to ip: " + ip + " port: " + port);
     m_Conn = new PomeloClient();
     m_Conn.NetWorkStateChangedEvent += (state) =>
     {
         Debug.Log("network state: " + state);
         if (NetState != null)
         {
             NetState.Invoke(state);
         }
     };
     m_Conn.initClient(ip, port, () =>
     {
         m_Conn.connect(user, (rt) =>
         {
             Dispatcher.Current.BeginInvoke(() =>
             {
                 action.Invoke(rt);
             });
         });
     });
 }
コード例 #3
0
    //建立起一条新的连接
    public void newSocket()
    {
        pclient = new PomeloClient();

        pclient.NetWorkStateChangedEvent += (state) =>
        {
            Debug.Log(state);
            //Console.WriteLine(state);
        };


        pclient.initClient(host, port, () =>
        {
            //The user data is the handshake user params
            JsonObject user = new JsonObject();
            pclient.connect(user, data =>
            {
                ConnectorSender.sendEnter();
                //pclient.request(Routes.CONNECTOR_ENTER, new JsonObject(), OnEnterConnector);
            });

            //把广播事件的名称都注册到pomelo中
            foreach (KeyValuePair <string, Action <JsonObject> > pair in BroadcastFact.callbacks)
            {
                this.registBroadcast(pair.Key);
            }
        });
    }
コード例 #4
0
    void OnQuery(JsonObject result)
    {
        if (Convert.ToInt32(result["code"]) == 200)
        {
            pomeloClient.disconnect();

            string connectorHost = (string)result["host"];
            int    connectorPort = Convert.ToInt32(result["port"]);

            pomeloClient = new PomeloClient();

            pomeloClient.initClient(connectorHost, connectorPort, () =>
            {
                //The user data is the handshake user params
                JsonObject user = new JsonObject();
                pomeloClient.connect(user, data =>
                {
                    Entry();
                });
            });

            // 请求到了connector数据后,跳转场景
            //_bNeedLoadScene = true;
        }
    }
コード例 #5
0
    //Login the chat application and new PomeloClient.
    void Login()
    {
        string host = "127.0.0.1";
        int    port = 33014;

        pc = new PomeloClient();

        pc.NetWorkStateChangedEvent += (state) =>
        {
            Debug.Log("NetWorkStateChangedEvent: " + state);
        };

        Debug.Log("Connecting to gate server: " + host + ":" + port);

        pc.initClient(host, port, () => {
            Debug.Log("pc.initClient callback.");


            pc.connect((data) => {
                Debug.Log("pc.connect callback.");
                JsonObject msg = new JsonObject();
                msg["uid"]     = userName;
                pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
                //pc.request("gate.gateHandler.queryEntry", msg, (response) => {
                //    Debug.Log("callback here!");
                //});
            });
        });
    }
コード例 #6
0
    void Awake()
    {
        callbacks = new Dictionary <string, CbFunc>();
        //初始化 PomeloClient
        client = new PomeloClient();
        client.initClient(host, port, () => {
            client.connect(null, (data) => {
                Debug.Log("connect back data" + data.ToString());
                JsonObject js = new JsonObject();
                js["uid"]     = 12234;
                client.request(router, js, (connectData) =>
                {
                    string conHost = connectData["host"].ToString();
                    int conPort    = int.Parse(connectData["port"].ToString());
                    Debug.Log(conHost + "#" + conPort.ToString());
                    client.disconnect();

                    client = new PomeloClient();
                    client.initClient(conHost, conPort, () =>
                    {
                        client.connect(null, (cb) => {
                        });
                    });
                });
            });
        });
    }
コード例 #7
0
ファイル: NetWorkMgr.cs プロジェクト: swiftliang/NewGame
        private IEnumerator _doGetGsInfo(Action <Constants> cb)
        {
            _GateClientConnection.disconnect();

            _gameSvrIP   = null;
            _gameSvrPort = -1;

            Constants code = Constants.INVALID;

            _GateClientConnection.initClient(_loginInfo.gateHost, _loginInfo.gatePort, () =>
            {
                _GateClientConnection.connect(null, (data) =>
                {
                    Debug.Log("connect gate data: " + data);
                    SimpleJson.JsonObject msg = new SimpleJson.JsonObject();
                    msg["uid"] = _loginInfo.uid;
                    //msg["token"] = _loginInfo.token;
                    _GateClientConnection.request(RequestMsg.REQUEST_CONNECTOR, msg, (result) =>
                    {
                        code         = (Constants)Convert.ToInt32(result.data["code"]);
                        _gameSvrIP   = (string)result.data["host"];
                        _gameSvrPort = Convert.ToInt32(result.data["port"]);
                    });
                });
            });

            yield return(new WaitUntil(() => code != Constants.INVALID));

            if (cb != null)
            {
                cb(code);
            }
        }
コード例 #8
0
        public static void Main()
        {
            JsonObject server = read("./server.json");
            string     host   = (string)server["host"];
            int        port   = Convert.ToInt32(server["port"]);

            Console.WriteLine("before init");

            pc = new PomeloClient(host, port);

            Console.WriteLine("before connect");
            pc.connect(null, delegate(JsonObject data){
                Console.WriteLine("after connect " + data.ToString());
                JsonObject msg = new JsonObject();

                msg["uid"] = 1;
                pc.request("gate.gateHandler.queryEntry", msg, onQuery);
            });

            while (true)
            {
                string str = Console.ReadLine();
                if (str != null)
                {
                    send(str);
                }
                System.Threading.Thread.Sleep(100);
            }
        }
コード例 #9
0
        public static void OnQuery(JsonObject result)
        {
            if (Convert.ToInt32(result["code"]) == 200)
            {
                pc.disconnect();

                string host = (string)result["host"];
                int port = Convert.ToInt32(result["port"]);
                pc = new PomeloClient();

                pc.NetWorkStateChangedEvent += (state) =>
                {
                    Console.WriteLine(state);
                };

                pc.initClient(host, port, () =>
                {
                    pc.connect(null, (data) =>
                    {
                        JsonObject userMessage = new JsonObject();
                        Console.WriteLine("on connect to connector!");

                        //Login
                        JsonObject msg = new JsonObject();
                        msg["username"] = "******";
                        msg["rid"] = "pomelo";

                        pc.request("connector.entryHandler.enter", msg, OnEnter);
                    });
                });
            }
        }
コード例 #10
0
ファイル: MainWindow.xaml.cs プロジェクト: soulkey99/byserver
 void OnQuery2(object sender, RoutedEventArgs e)
 {
     pc2 = new PomeloClient(this.ipAddr2.Text, 3014);
     pc2.connect(null, delegate(JsonObject data) {
         JsonObject msg = new JsonObject();
         msg["userID"]  = "demo2";
         pc2.request("gate.gateHandler.queryEntry", msg, delegate(JsonObject result) {
             if (Convert.ToInt32(result["statusCode"]) == 900)
             {
                 string host = (string)result["host"];
                 int port    = Convert.ToInt32(result["port"]);
                 pc2.disconnect();
                 pc2.Dispose();
                 pc2   = null;
                 host2 = host;
                 port2 = port;
                 this.Dispatcher.BeginInvoke((Action)(() =>
                 {
                     this.Status21.Text = "success, " + host + ":" + port.ToString();
                 }));
                 Log2("query success, " + host + ":" + port.ToString());
             }
             else
             {
                 this.Dispatcher.BeginInvoke((Action)(() =>
                 {
                     this.Status21.Text = "error, " + result["message"];
                 }));
                 Log2("error, " + result["message"]);
             }
         });
     });
 }
コード例 #11
0
ファイル: NetworkClient.cs プロジェクト: zj831007/knight
 private bool ConnectPomeloServer(Action OnConnectCompleted)
 {
     return(mClient.connect(null, (rProtocolMsg) => {
         Debug.Log("Connection Established: " + rProtocolMsg.ToString());
         UtilTool.SafeExecute(OnConnectCompleted);
     }));
 }
コード例 #12
0
 public void Connect(Action <JsonObject> cb)
 {
     if (pclient != null)
     {
         pclient.connect(null, cb);
     }
 }
コード例 #13
0
    void OnQuery(JsonObject result)
    {
        Debug.Log("OnQuery called. Acquired data from gate server.");
        if (Convert.ToInt32(result["code"]) == 200)
        {
            pc.disconnect();

            string host = (string)result["host"];
            int    port = Convert.ToInt32(result["port"]);


            Debug.Log("Connecting to connector server: " + host + ":" + port);
            pc = new PomeloClient();
            pc.initClient(host, port, () => {
                pc.connect((data) =>
                {
                    Entry();
                });
            });
        }
        else
        {
            Debug.Log("Connection error.");
        }
    }
コード例 #14
0
    //Login the chat application and new PomeloClient.
    void Login()
    {
        userName = infield_username.text; // 获取输入框中的信息

        if (userName == "")
        {
            return;
        }

        string host = "127.0.0.1"; // gate的host和port
        int    port = 3014;

        pomeloClient = new PomeloClient();

        //listen on network state changed event
        pomeloClient.NetWorkStateChangedEvent += (state) =>
        {
            Debug.logger.Log("CurrentState is:" + state);
        };

        // 请求gate服务器,得到connector服务器的host和clientPort
        pomeloClient.initClient(host, port, () =>
        {
            // user 消息传递给 gate.gateHandler.queryEntry
            JsonObject user = new JsonObject();
            user["uid"]     = userName;
            pomeloClient.connect(user, data =>
            {
                //process handshake call back data
                JsonObject msg = new JsonObject();
                msg["uid"]     = userName;
                pomeloClient.request("gate.gateHandler.queryEntry", msg, OnQuery);
            });
        });
    }
コード例 #15
0
ファイル: ConnectionManager.cs プロジェクト: PenpenLi/Nav
    /// <summary>
    /// 与服务器器建立连接
    /// </summary>
    /// <param name="conResult">Con result.</param>
    public void Connect(Action <bool> conResult)
    {
        connectResultCallback = conResult;
        if (pclient != null && conResult != null)
        {
            Debug.Log("(pclient != null && conResult != null)");
            InvokeConnectResult(true);
            return;
        }

        ChangeConnectStatus(ConnectStatus.CONNECTING);
        EventDispatcher.Instance().RegistEventListener(NetDataRequestTip.NET_REQUEST_START, NetDataRequestTip.startReq);
        EventDispatcher.Instance().RegistEventListener(NetDataRequestTip.NET_REQUEST_END, NetDataRequestTip.endReq);
        EventDispatcher.Instance().RegistEventListener(NetDataRequestTip.NET_CONNECT_CLOSE, NetDataRequestTip.ConnectClose);
        EventDispatcher.Instance().DispatchEvent(NetDataRequestTip.NET_REQUEST_START, null);

        pclient = new PomeloClient();
        pclient.NetWorkStateChangedEvent += OnGateServerNetWorkStateChange;
        try{
            pclient.initClient(CGNetConst.HOST, CGNetConst.POST, () => {
                pclient.connect(null, conData1 => {
                    Debug.Log("Gate服务器连接成功!");
                    pclient.request(CGNetConst.ROUTE_LOGIN, delegate(JsonObject jsonObject) {
                        Debug.Log("PARA_CODE = " + jsonObject [CGNetConst.PARA_CODE]);
                        if (Convert.ToInt32(jsonObject [CGNetConst.PARA_CODE]) == CGNetConst.RESULT_CODE_SUC)
                        {
                            Disconnect(true);
                            Debug.Log("与Gate服务器断开连接,准备连接游戏服务器……");
                            Debug.Log("host=" + (string)jsonObject [CGNetConst.PARA_HOST] + "   port=" + jsonObject [CGNetConst.PARA_PORT]);
                            pclient = new PomeloClient();
                            pclient.NetWorkStateChangedEvent += OnNetWorkStateChange;
                            pclient.initClient((string)jsonObject [CGNetConst.PARA_HOST], Convert.ToInt32(jsonObject [CGNetConst.PARA_PORT]), () => {
                                pclient.connect(null, conData2 => {
                                    ChangeConnectStatus(ConnectStatus.CONNECTED);
                                    Debug.Log("游戏服务器连接成功!");

//                                    if(conResult != null)
//                                    {
//                                        conResult(true);
//                                    }
                                });
                            });
                        }
                        else
                        {
                            Debug.Log("Connect faild!");
                            InvokeConnectResult(false);
//                            if(conResult != null)
//                            {
//                                conResult(false);
//                            }
                        }
                    });
                });
            });
        }catch (Exception e)
        {
            Debug.Log(e.ToString());
        }
    }
コード例 #16
0
        public static void OnQuery(JsonObject result)
        {
            if (Convert.ToInt32(result["code"]) == 200)
            {
                pc.disconnect();

                string host = (string)result["host"];
                int    port = Convert.ToInt32(result["port"]);
                pc = new PomeloClient();

                pc.NetWorkStateChangedEvent += (state) =>
                {
                    Console.WriteLine(state);
                };

                pc.initClient(host, port, () =>
                {
                    pc.connect(null, (data) =>
                    {
                        JsonObject userMessage = new JsonObject();
                        Console.WriteLine("on connect to connector!");

                        //Login
                        JsonObject msg  = new JsonObject();
                        msg["username"] = "******";
                        msg["rid"]      = "pomelo";

                        pc.request("connector.entryHandler.enter", msg, OnEnter);
                    });
                });
            }
        }
コード例 #17
0
    void OnQuery(JsonObject result)
    {
        if (Convert.ToInt32(result["code"]) == 200)
        {
            pc.disconnect();

            string host = (string)result["host"];
            int    port = Convert.ToInt32(result["port"]);
            pc = new PomeloClient();
            pc.initClient(host, port);
            pc.connect(null, (data) =>
            {
                JsonObject conectorMessage = new JsonObject();
                conectorMessage.Add("deviceId", deviceId);
                pc.request("connector.entryHandler.entry", conectorMessage, (ret) =>
                {
                    if (Convert.ToInt32(ret["code"]) == 200)
                    {
                        isConnected = true;
                        EventsListen();
                        Debug.Log("...... " + data);
                    }
                });
            });
        }
    }
コード例 #18
0
    private void Connect()
    {
        client = new PomeloClient();
        client.initClient(url, port, () =>
        {
            Debug.Log("Pomelo client init success!");
        });

        JsonNode user = new JsonClass();

        user.Add("user", new JsonData("Winddy"));
        user.Add("pwd", new JsonData("123"));

        bool result = client.connect(user, new System.Action <JsonNode>(OnConnection));

        if (result)
        {
            Debug.Log("Connect success!");
        }
        else
        {
            Debug.Log("Connect failed!");
        }

        //ClientTest.loginTest("127.0.0.1", 3014);
    }
コード例 #19
0
    //Login the chat application and new PomeloClient.
    void Login()
    {
        //string host = "120.27.163.31";
        string host = "127.0.0.1";
        int    port = 3014;

        pomeloClient = new PomeloClient();

        //listen on network state changed event
        pomeloClient.NetWorkStateChangedEvent += (state) =>
        {
            Debug.logger.Log("CurrentState is:" + state);
        };

        pomeloClient.initClient(host, port, () =>
        {
            //The user data is the handshake user params
            JsonObject user = new JsonObject();
            //user["uid"] = userName;
            pomeloClient.connect(user, data =>
            {
                //process handshake call back data
                JsonObject msg = new JsonObject();
                msg["uid"]     = userName;
                pomeloClient.request("gate.gateHandler.queryEntry", msg, OnQuery);
            });
        });
    }
コード例 #20
0
 public void Connect()
 {
     pc = new PomeloClient();
     pc.initClient(host, port);
     pc.connect(null, (data) => {
         JsonObject msg  = new JsonObject();
         msg["deviceId"] = deviceId;
         msg["id"]       = 1;
         pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
     });
 }
コード例 #21
0
    public static void getGameServerList(Action <JsonObject> action)
    {
        _gameClient = new PomeloClient(_gateHost, _gatePort);
        _gameClient.connect(null, (data) => {
            JsonObject msg = new JsonObject();
            //todo: 从文件导入,作为唯一标示,OR再议唯一
            msg["uid"] = System.Guid.NewGuid().ToString();

            _gameClient.request("gate.gateHandler.queryEntry", msg, action);
        });
    }
コード例 #22
0
 /// <summary>
 ///  选择服务器登陆方式
 /// </summary>
 /// <param name="host">Host.</param>
 /// <param name="ip">Ip.</param>
 public void SelectServer(string host, int port)
 {
     _connection = createConnect();
     _ip         = host;
     _port       = port;
     _connection.InitClient(_ip, _port, msgObj => {
         _connection.connect(null, (data) => {
             _connectSuccess = true;
             _canLogin       = true;
         });
     });
 }
コード例 #23
0
    //Login the chat application and new PomeloClient.
    void Login()
    {
        string host = "127.0.0.1";
        int    port = 3014;

        pc = new PomeloClient(host, port);
        pc.connect(null, (data) => {
            JsonObject msg = new JsonObject();
            msg["uid"]     = userName;
            pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
        });
    }
コード例 #24
0
 private static void startConnect(string host, int port)
 {
     pc = new PomeloClient(host, port);
     pc.connect(null, delegate(JsonObject data) {
         pc.on("onChat", msg => Console.WriteLine(msg["from"] + " : " + msg["msg"]));
         pc.on("onAdd", msg => Console.WriteLine("onAdd : " + msg));
         pc.on("onLeave", msg => Console.WriteLine("onLeave : " + msg));
         pc.on("disconnect", msg => Console.WriteLine("disconnect : " + msg));
         Console.WriteLine("connect to connector " + data.ToString());
         login();
     });
 }
コード例 #25
0
 //todo  这里需要重新整理优化
 void OnQuery(JsonObject result)
 {
     if (Convert.ToInt32(result["code"]) == 200)
     {
         pomeloClient.disconnect();
         string host = (string)result["host"];
         int    port = Convert.ToInt32(result["port"]);
         pomeloClient = new PomeloClient(host, port);
         pomeloClient.connect(null, (data) =>
         {
         });
     }
 }
コード例 #26
0
 private void Start()
 {
     _connection = createConnect();
     _connection.InitClient(_ip, _port, msgObj =>
     {
         _connection.connect(null, data =>
         {
             //process handshake call back data
             JsonObject msg = new JsonObject();
             sendMsg(LobbyProtocol.P_LOBBY_REQ_CONNECT, msg, onRespConnet);
         });
     });
 }
コード例 #27
0
 public static void Init(string host, int port, int uid, Action <JsonObject> act)
 {
     cli = new PomeloClient();
     cli.initClient(host, port, () => {
         cli.connect((hs) => {
             JsonObject msg = new JsonObject();
             msg ["uid"]    = uid;
             cli.request("gate.gateHandler.queryEntry", msg, data => {
                 cli.disconnect();
                 Entry(Convert.ToString(data ["host"]), Convert.ToInt32(data ["port"]), uid, act, data);
             });
         });
     });
 }
コード例 #28
0
    public void Connect(string host, int port, LuaInterface.LuaFunction func)
    {
        pc = new PomeloClient();
        pc.initClient(host, port);
        pc.connect(null, (data) => {
            JsonObject msg  = new JsonObject();
            msg["deviceId"] = deviceId;
            msg["id"]       = 1;
            pc.request("gate.gateHandler.queryEntry", msg, (result) => {
                Debug.Log("--------------------------------------");
                Debug.Log(result.ToString());
                Debug.Log("--------------------------------------");
                if (Convert.ToInt32(result["code"]) == 200)
                {
                    pc.disconnect();

                    string h = (string)result["host"];
                    int p    = Convert.ToInt32(result["port"]);
                    pc       = new PomeloClient();
                    pc.initClient(h, p);
                    pc.connect(null, (dd) =>
                    {
                        JsonObject conectorMessage = new JsonObject();
                        conectorMessage.Add("deviceId", deviceId);
                        pc.request("connector.entryHandler.entry", conectorMessage, (ret) =>
                        {
                            Debug.Log("--------------------------------------");
                            Debug.Log(ret.ToString());
                            Debug.Log("--------------------------------------");
                            if (Convert.ToInt32(ret["code"]) == 200)
                            {
                                isConnected = true;
                                EventsListen();
                            }

                            if (func != null)
                            {
                                PomeloPackage pkg = new PomeloPackage();
                                pkg.luaFunc       = func;
                                pkg.ReturnData    = ret.ToString();
                                Debug.Log("!!!!!!!!!!!!!!!!!!!! " + pkg.ReturnData);
                                AddResultPackage(pkg);
                            }
                        });
                    });
                }
            });
        });
    }
コード例 #29
0
        public static void loginTest(string host, int port)
        {
            pc = new PomeloClient(host, port);

            pc.connect(null, data=>{
                Console.WriteLine("on data back" + data.ToString());
                JsonObject msg  = new JsonObject();
                msg["uid"] = 111;
                pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
            });

            while(true){
                System.Threading.Thread.Sleep(100);
            };
        }
コード例 #30
0
        /// <summary>
        /// 连接connector服务器
        /// </summary>
        /// <param name="result"></param>
        void LoginConnectorServer(JsonObject result)
        {
            string host = (string)result["host"];
            int    port = Convert.ToInt32(result["port"]);

            Console.WriteLine("Connector Server 分配成功,开始连接:" + host + ":" + port);

            _pomelo = new PomeloClient(host, port);

            _pomelo.connect(null, (data) =>
            {
                Console.WriteLine("成功连接 connector server:\n " + FormatJson(data.ToString()));
                JoinChannel(tb_name.Text, tb_channel.Text);
            });
        }
コード例 #31
0
 // Use this for initialization
 void Start()
 {
     //pomeloClient = new PomeloClient(TransportType.TCP);
     pomeloClient = new PomeloClient(TransportType.SSL);
     pomeloClient.NetWorkStateChangedEvent += OnNetWorkStateChange;
     pomeloClient.initClient(gateHost, gatePort, () => {
         JsonObject user = new JsonObject();
         pomeloClient.connect(user, data =>
         {
             JsonObject msg = new JsonObject();
             msg["uid"]     = "hello";
             pomeloClient.request("gate.gateHandler.queryEntry", msg, OnGateQuery);
         });
     });
 }
コード例 #32
0
        public static void OnQuery(JsonObject result)
        {
            if(Convert.ToInt32(result["code"]) == 200){
                Console.WriteLine("dis connect");
                pc.disconnect();

                string host = (string)result["host"];
                int port = Convert.ToInt32(result["port"]);
                pc = new PomeloClient(host, port);
                pc.connect(null, (data)=>{
                    JsonObject userMessage = new JsonObject();
                    Console.WriteLine("on connect to connector!");
                });
            }
        }
コード例 #33
0
 public void ConnectGameServer(string host, int port)
 {
     // pc.disconnect();
     if (pc != null)
     {
         pc.disconnect();
     }
     pc               = new PomeloClient(host, port);
     _port            = port;
     pc.OnDisconnect += OnOnDisconnect;
     pc.connect(null, (data) =>
     {
         SocketMsgManager.AddListener();
         SocketMsgManager.RequestEntry();
     });
 }
コード例 #34
0
        public static void loginTest(string host, int port)
        {
            pc = new PomeloClient();

            pc.NetWorkStateChangedEvent += (state) =>
            {
                Console.WriteLine(state);
            };

            pc.initClient(host, port, () =>
            {
                pc.connect(null, data =>
                {

                    Console.WriteLine("on data back" + data.ToString());
                    JsonObject msg = new JsonObject();
                    msg["uid"] = 111;
                    pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
                });
            });
        }
コード例 #35
0
        public static void OnQuery(JsonObject result)
        {
            if(Convert.ToInt32(result["code"]) == 200){
                pc.disconnect();

                string host = (string)result["host"];
                int port = Convert.ToInt32(result["port"]);
                pc = new PomeloClient(host, port);
                pc.connect(null, (data)=>{
                    Console.WriteLine("on connect to connector!");
                    pc.on(PomeloClient.EVENT_DISCONNECT, onDisconnect);

                    //Login
                    JsonObject msg  = new JsonObject();
                    msg["username"] = "******";
                    msg["rid"] = "pomelo";

                    pc.request("connector.entryHandler.enter", msg, OnEnter);
                });
            }
        }