コード例 #1
0
        public override void OnReceived(Packet thePacket)
        {
            Logger.DEBUG(string.Empty);
            try
            {
                int    num   = thePacket.theContent.Length - this.detectedHeaderLength;
                byte[] array = new byte[num];
                Array.Copy(thePacket.theContent, this.detectedHeaderLength, array, 0, num);
                string @string = Encoding.get_UTF8().GetString(array);
                Dictionary <string, object> dictionary = Json.Deserialize(@string) as Dictionary <string, object>;
                string text             = dictionary.get_Item("data") as string;
                byte[] encodedDataBytes = Convert.FromBase64String(text);
                string text2            = MsdkTea.Decode(encodedDataBytes);
                if (text2.get_Length() > 0)
                {
                    Logger.DEBUG_LOGCAT(text2);
                    Dictionary <string, object> content = Json.Deserialize(text2) as Dictionary <string, object>;
                    Message message = new Message();
                    message.status  = 0;
                    message.action  = this.theAction;
                    message.content = content;
                    Pandora.Instance.GetNetLogic().EnqueueResult(message);
                    this.theAction = null;
                }
            }
            catch (Exception ex)
            {
                Logger.ERROR(ex.get_StackTrace());
            }
            long uniqueSocketId = base.GetUniqueSocketId();

            Pandora.Instance.GetNetLogic().Close(uniqueSocketId);
        }
コード例 #2
0
        public void SetUserData(Dictionary <string, string> dictPara)
        {
            string formatMsg = Json.Serialize(dictPara);

            Logger.DEBUG_LOGCAT(formatMsg);
            if (this.userData.IsRoleEmpty())
            {
                this.userData.Assgin(dictPara);
                if (this.pandoraImpl != null)
                {
                    this.pandoraImpl.Bootup();
                }
            }
            else
            {
                this.userData.Refresh(dictPara);
            }
        }
コード例 #3
0
 public void GetRemoteConfig(Action <int, Dictionary <string, object> > action)
 {
     Logger.DEBUG(string.Empty);
     try
     {
         string configUrl = "http://apps.game.qq.com/cgi-bin/api/tplay/" + Pandora.Instance.GetUserData().sAppId + "_cloud.cgi";
         Logger.DEBUG_LOGCAT(configUrl);
         Uri uri = new Uri(configUrl);
         Action <IPHostEntry> resultAction = delegate(IPHostEntry entry)
         {
             Logger.DEBUG(configUrl + " dns done");
             if (entry != null && entry.get_AddressList().Length > 0)
             {
                 IPAddress[] addressList = entry.get_AddressList();
                 int         num         = new Random().Next(addressList.Length);
                 long        num2        = this.SpawnTCPSession(addressList[num], (ushort)uri.get_Port(), new ConfigHandler(action, configUrl));
                 if (num2 > 0L)
                 {
                     Logger.DEBUG(addressList[num].ToString());
                 }
                 else
                 {
                     Logger.ERROR(string.Empty);
                     action.Invoke(-1, new Dictionary <string, object>());
                 }
             }
             else
             {
                 Logger.ERROR(string.Empty);
                 action.Invoke(-1, new Dictionary <string, object>());
             }
         };
         this.AsyncGetHostEntry(uri.get_Host(), resultAction);
     }
     catch (Exception ex)
     {
         action.Invoke(-1, new Dictionary <string, object>());
         Logger.ERROR(ex.get_Message() + ":" + ex.get_StackTrace());
     }
 }
コード例 #4
0
        public void Init()
        {
            Logger.DEBUG_LOGCAT(string.Empty);
            if (this.isInited)
            {
                return;
            }
            string temporaryCachePath = Application.temporaryCachePath;

            this.logPath             = temporaryCachePath + "/Pandora/logs";
            this.cachePath           = temporaryCachePath + "/Pandora/cache";
            this.imgPath             = this.cachePath + "/imgs";
            this.cookiePath          = this.cachePath + "/cookies";
            this.tempPath            = temporaryCachePath + "/Pandora/temp";
            this.streamingAssetsPath = Application.streamingAssetsPath + "/Pandora";
            this.pandoraGameObject   = new GameObject("Pandora GameObject");
            Object.DontDestroyOnLoad(this.pandoraGameObject);
            this.pandoraImpl = this.pandoraGameObject.AddComponent <PandoraImpl>();
            this.logger      = this.pandoraGameObject.AddComponent <Logger>();
            this.pandoraGameObject.AddComponent <MidasUtil>();
            this.pandoraImpl.Init();
            this.isInited = true;
        }
コード例 #5
0
        public override void OnConnected()
        {
            Logger.DEBUG(string.Empty);
            long uniqueSocketId = base.GetUniqueSocketId();
            Action <int, Dictionary <string, object> > action = delegate(int status, Dictionary <string, object> content)
            {
                try
                {
                    UserData userData = Pandora.Instance.GetUserData();
                    string   text     = string.Concat(new string[]
                    {
                        "openid=",
                        userData.sOpenId,
                        "&partition=",
                        userData.sPartition,
                        "&gameappversion=",
                        userData.sGameVer,
                        "&areaid=",
                        userData.sArea,
                        "&appid=",
                        userData.sAppId,
                        "&acctype=",
                        userData.sAcountType,
                        "&platid=",
                        userData.sPlatID,
                        "&sdkversion=",
                        Pandora.Instance.GetSDKVersion(),
                        "&_pdr_time=",
                        Utils.NowSeconds().ToString()
                    });
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    dictionary.set_Item("openid", userData.sOpenId);
                    dictionary.set_Item("partition", userData.sPartition);
                    dictionary.set_Item("gameappversion", userData.sGameVer);
                    dictionary.set_Item("areaid", userData.sArea);
                    dictionary.set_Item("acctype", userData.sAcountType);
                    dictionary.set_Item("platid", userData.sPlatID);
                    dictionary.set_Item("appid", userData.sAppId);
                    dictionary.set_Item("sdkversion", Pandora.Instance.GetSDKVersion());
                    string rawData = Json.Serialize(dictionary);
                    string text2   = MsdkTea.Encode(rawData);
                    string text3   = "{\"data\":\"" + text2 + "\",\"encrypt\" : \"true\"}";
                    Uri    uri     = new Uri(this.configUrl);
                    string text4   = string.Concat(new string[]
                    {
                        "POST ",
                        uri.get_AbsolutePath(),
                        "?",
                        text,
                        " HTTP/1.1\r\nHost:",
                        uri.get_Host(),
                        "\r\nAccept:*/*\r\nUser-Agent:Pandora(",
                        Pandora.Instance.GetSDKVersion(),
                        ")\r\nContent-Length:",
                        text3.get_Length().ToString(),
                        "\r\nConnection: keep-alive\r\n\r\n",
                        text3
                    });
                    Logger.DEBUG_LOGCAT(text4);
                    byte[] bytes = Encoding.get_UTF8().GetBytes(text4);
                    Pandora.Instance.GetNetLogic().SendPacket(uniqueSocketId, bytes);
                }
                catch (Exception ex)
                {
                    Logger.ERROR(ex.get_Message());
                    Pandora.Instance.GetNetLogic().Close(uniqueSocketId);
                }
            };
            Message message = new Message();

            message.status = 0;
            message.action = action;
            Pandora.Instance.GetNetLogic().EnqueueResult(message);
        }