コード例 #1
0
ファイル: LoginGUI.cs プロジェクト: sfszh/pomelo-unitychat
    //Login the chat application and new PomeloClient.
    void Login()
    {
        string url = "http://114.113.202.141:3088";

        pclient = new PomeloClient(url);
        pclient.init();
        JsonObject userMessage = new JsonObject();

        userMessage.Add("uid", userName);
        pclient.request("gate.gateHandler.queryEntry", userMessage, (data) => {
            System.Object code = null;
            if (data.TryGetValue("code", out code))
            {
                if (Convert.ToInt32(code) == 500)
                {
                    return;
                }
                else
                {
                    pclient.disconnect();
                    pclient = null;
                    System.Object host, port;
                    if (data.TryGetValue("host", out host) && data.TryGetValue("port", out port))
                    {
                        pclient = new PomeloClient("http://" + "114.113.202.141" + ":" + port.ToString());
                        pclient.init();
                        Entry();
                    }
                }
            }
        });
    }
コード例 #2
0
ファイル: LoginGUI.cs プロジェクト: NetEase/pomelo-unitychat
 //Login the chat application and new PomeloClient.
 void Login()
 {
     string url = "http://114.113.202.141:3088";
     pclient = new PomeloClient(url);
     pclient.init();
     JsonObject userMessage = new JsonObject();
     userMessage.Add("uid", userName);
     pclient.request("gate.gateHandler.queryEntry", userMessage, (data)=>{
         System.Object code = null;
         if(data.TryGetValue("code", out code)){
             if(Convert.ToInt32(code) == 500) {
                 return;
             } else {
                 pclient.disconnect();
                 pclient = null;
                 System.Object host, port;
                 if (data.TryGetValue("host", out host) && data.TryGetValue("port", out port)) {
                     pclient = new PomeloClient("http://" + "114.113.202.141" + ":" + port.ToString());
                     pclient.init();
                     Entry();
                 }
             }
         }
     });
 }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        JsonObject jsonConfig = ReadFromJsonFile("./server.json");
        string szURL = (string)jsonConfig["host"];
        m_PomeloClient = new PomeloClient(szURL);
        m_PomeloClient.init();

        string szRoute = "connector.entryHandler.entry";
        m_PomeloClient.On(szRoute, (data) =>
        {
            Debug.Log(data.ToString());
        });
        Debug.Log("Pomelo client init.");
    }
コード例 #4
0
ファイル: JoviosNetworking.cs プロジェクト: Ar2rZ/Cards
    public void NodeLinux()
    {
        string url = "54.186.22.19:3014";

        if (!has_internet)
        {
            has_internet = CheckForServerConnection();
            if (!has_internet)
            {
                Debug.Log("no internet connection");
                return;
            }
        }
        if (pclient != null)
        {
            Disconnect();
        }
        pclient = new PomeloClient(url);
        pclient.init();
        JsonObject userMessage = new JsonObject();

        userMessage.Add("uid", parser.GetDeviceID());
        pclient.request("gate.gateHandler.queryEntry", userMessage, (data) => {
            System.Object code = null;
            if (data.TryGetValue("code", out code))
            {
                if (Convert.ToInt32(code) == 500)
                {
                    return;
                }
                else
                {
                    pclient.disconnect();
                    pclient = null;
                    System.Object host, port;
                    if (data.TryGetValue("host", out host) && data.TryGetValue("port", out port))
                    {
                        pclient = new PomeloClient("http://" + "54.186.22.19" + ":" + port.ToString());
                        pclient.init();
                        pclient.On("onAdd", (data3) => {
                            Dictionary <string, object> packet = Json.Deserialize(data3.ToString()) as Dictionary <string, object>;
                            Dictionary <string, object> body   = (Dictionary <string, object>)packet["body"];
                            parser.OnAdd((string)body["user"]);
                        });
                        pclient.On("onChat", (data2) => {
                            Dictionary <string, object> packet = Json.Deserialize(data2.ToString()) as Dictionary <string, object>;
                            Dictionary <string, object> body   = (Dictionary <string, object>)packet["body"];
                            AddMessage((string)body["msg"]);
                        });
                        pclient.On("onLeave", (data4) => {
                            Dictionary <string, object> packet = Json.Deserialize(data4.ToString()) as Dictionary <string, object>;
                            Dictionary <string, object> body   = (Dictionary <string, object>)packet["body"];
                            parser.OnLeave((string)body["user"]);
                        });
                        pclient.On("onError", (data5) => {
                            System.Object nodeLinuxError;
                            data5.TryGetValue("body", out nodeLinuxError);
                            Debug.Log(nodeLinuxError.ToString());
                        });
                        if (parser.GetGameCode() == "" || parser.GetGameCode() == null)
                        {
                            NewGame();
                        }
                        else
                        {
                            JoinNodeLinux();
                        }
                    }
                }
            }
        });
    }