コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            //Establish a world connection.
            if (ws_ != null)
            {
                string reply = ws_.RecvString();
                if (reply != null)
                {
                    //deserialize
                    //eqemu json start
                    OpcodeFromServerClass IdChecker1 = JsonConvert.DeserializeObject <OpcodeFromServerClass> (reply);

                    if (IdChecker1.id != null && IdChecker1.id == "token_auth_id")
                    {
                        if (CSel != null)
                        {
                            CSel.LoginStatus.text = "Auth successful. Proceeding...";
                        }
                    }
                    if (IdChecker1.method == "Client.Opcode")
                    {
                        byte[] RawData = null;
                        if (Convert.ToInt32(IdChecker1.datasize) > 0)
                        {
                            RawData = System.Convert.FromBase64CharArray(IdChecker1.data.ToCharArray(), 0, IdChecker1.data.Length);
                        }

                        if (opcodeDict.ContainsKey(IdChecker1.opcode))
                        {
                            string RawOp = IdChecker1.opcode;

                            int length = 0;
                            if (RawData != null)
                            {
                                length = RawData.Length;
                            }
                            opcodeDict[RawOp](RawData, length);
                        }
                    }
                }
                if (ws_.Error != null)
                {
                    LogError("Error: " + ws_.Error);
                    ws_ = null;
                    if (CSel != null)
                    {
                        CSel.BackToLogin();
                    }
                }
            }
        }