Пример #1
0
 private void Update()
 {
     try
     {
         if (this.netLogic != null)
         {
             this.netLogic.Drive();
         }
         if (this.luaMgr != null)
         {
             this.luaMgr.Update();
         }
         if (this.bootupStatus == PandoraImpl.BootupStatus.kReadConfigFailed)
         {
             int num = Utils.NowSeconds();
             if (this.lastReBootTime + 10 < num)
             {
                 this.lastReBootTime = num;
                 this.Bootup();
             }
         }
         else if (this.bootupStatus >= PandoraImpl.BootupStatus.kReadConfigDone && this.totalSwitch && this.loadBaseAtlasSucc)
         {
             this.HotUpdate();
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #2
0
        private void ProcessBrokerHeartbeat()
        {
            int num = Utils.NowSeconds();

            if (this.lastRecvBrokerHeartbeatRspTime >= this.lastSendBrokerHeartbeatReqTime)
            {
                if (num >= this.lastSendBrokerHeartbeatReqTime + NetLogic.brokerHeartbeatIntervalInSecs)
                {
                    this.SendHeartbeatToBroker();
                }
            }
            else if (num >= this.lastSendBrokerHeartbeatReqTime + NetLogic.brokerHeartbeatTimeoutInSecs)
            {
                if (this.brokerHeartbeatTimeoutRetryCnt < NetLogic.maxBrokerHeartbeatTimeoutRetryCnt)
                {
                    Logger.WARN("Broker heartbeat is timeout, try again later, retryCnt=" + this.brokerHeartbeatTimeoutRetryCnt);
                    this.SendHeartbeatToBroker();
                    this.brokerHeartbeatTimeoutRetryCnt++;
                }
                else
                {
                    Logger.ERROR("Broker heartbeat is timeout, the connection to broker will be closed");
                    this.Close(this.brokerUniqueSocketId);
                    this.ResetBrokerHeartbeatVars();
                }
            }
        }
Пример #3
0
 public void CallBroker(uint callId, string jsonData, int cmdId)
 {
     Logger.DEBUG(string.Empty);
     try
     {
         PendingRequest pendingRequest = new PendingRequest();
         pendingRequest.createTime = Utils.NowSeconds();
         pendingRequest.seqNo      = callId;
         Dictionary <string, object> dictionary = new Dictionary <string, object>();
         UserData userData = Pandora.Instance.GetUserData();
         dictionary.set_Item("seq_id", callId);
         dictionary.set_Item("cmd_id", cmdId);
         dictionary.set_Item("type", 1);
         dictionary.set_Item("from_ip", "10.0.0.108");
         dictionary.set_Item("process_id", 1);
         dictionary.set_Item("mod_id", 10);
         dictionary.set_Item("version", Pandora.Instance.GetSDKVersion());
         dictionary.set_Item("body", jsonData);
         dictionary.set_Item("app_id", userData.sAppId);
         string text   = Json.Serialize(dictionary);
         string text2  = MinizLib.Compress(text.get_Length(), text);
         byte[] array  = Convert.FromBase64String(text2);
         int    num    = IPAddress.HostToNetworkOrder(array.Length);
         byte[] bytes  = BitConverter.GetBytes(num);
         byte[] array2 = new byte[bytes.Length + array.Length];
         Array.Copy(bytes, 0, array2, 0, bytes.Length);
         Array.Copy(array, 0, array2, bytes.Length, array.Length);
         pendingRequest.data = array2;
         this.brokerPendingRequests.Enqueue(pendingRequest);
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #4
0
 public void CallGame(string strCmdJson)
 {
     Logger.DEBUG(strCmdJson);
     try
     {
         Dictionary <string, object> dictionary  = Json.Deserialize(strCmdJson) as Dictionary <string, object>;
         Dictionary <string, string> dictionary2 = new Dictionary <string, string>();
         using (Dictionary <string, object> .Enumerator enumerator = dictionary.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 KeyValuePair <string, object> current = enumerator.get_Current();
                 if (current.get_Value() == null)
                 {
                     Logger.DEBUG(strCmdJson);
                     dictionary2.set_Item(current.get_Key(), string.Empty);
                 }
                 else
                 {
                     dictionary2.set_Item(current.get_Key(), current.get_Value() as string);
                 }
             }
         }
         if (this.callbackForGame != null)
         {
             this.callbackForGame.Invoke(dictionary2);
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_Message() + ":" + ex.get_StackTrace());
     }
 }
Пример #5
0
        public int ShowGameIcon(GameObject go, int rankClass, int rankGrade)
        {
            int result = -1;

            if (this.callbackForGameImgPath == null || this.callbackForSetGameImgByPath == null)
            {
                Logger.ERROR("the callback for setting game icon is null");
                return(result);
            }
            string text = this.callbackForGameImgPath.Invoke(rankClass, rankGrade);

            if (!string.IsNullOrEmpty(text))
            {
                result = this.callbackForSetGameImgByPath.Invoke(go, text);
            }
            else
            {
                Logger.ERROR(string.Concat(new string[]
                {
                    "the path for rankClass:",
                    rankClass.ToString(),
                    " rankGrade:",
                    rankGrade.ToString(),
                    " is null or empty"
                }));
            }
            return(result);
        }
Пример #6
0
        public static void SaveDnsCacheToFile(Dictionary <string, IPHostEntry> dnsCache)
        {
            Dictionary <string, List <string> > dictionary = new Dictionary <string, List <string> >();

            using (Dictionary <string, IPHostEntry> .Enumerator enumerator = dnsCache.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <string, IPHostEntry> current = enumerator.get_Current();
                    if (current.get_Value().get_AddressList().Length > 0)
                    {
                        List <string> list        = new List <string>();
                        IPAddress[]   addressList = current.get_Value().get_AddressList();
                        for (int i = 0; i < addressList.Length; i++)
                        {
                            IPAddress iPAddress = addressList[i];
                            list.Add(iPAddress.ToString());
                        }
                        dictionary.set_Item(current.get_Key(), list);
                    }
                }
            }
            string dnsCacheFileName = Utils.GetDnsCacheFileName();

            try
            {
                string text = Json.Serialize(dictionary);
                Logger.DEBUG(text);
                File.WriteAllText(dnsCacheFileName, text);
            }
            catch (Exception ex)
            {
                Logger.ERROR(ex.get_StackTrace());
            }
        }
Пример #7
0
 private void LoadFonts()
 {
     Logger.DEBUG(string.Empty);
     string[] fontResources = Pandora.Instance.GetFontResources();
     for (int i = 0; i < fontResources.Length; i++)
     {
         GameObject gameObject = Resources.Load(fontResources[i]) as GameObject;
         if (gameObject != null)
         {
             Font font = gameObject.GetComponent <Text>().get_font();
             if (font != null)
             {
                 Logger.DEBUG(font.name + " loaded!");
                 this.fonts.set_Item(font.name.ToLower(), font);
             }
             else
             {
                 Logger.ERROR("Font of " + fontResources[i] + " is null");
             }
         }
         else
         {
             Logger.ERROR(fontResources[i] + " load error");
         }
     }
 }
Пример #8
0
 private void LoadCacheMeta()
 {
     try
     {
         if (!File.Exists(this.cacheMetaFile))
         {
             FileStream fileStream = new FileStream(this.cacheMetaFile, 2);
             fileStream.Close();
         }
         string text = File.ReadAllText(this.cacheMetaFile);
         if (text != string.Empty)
         {
             this.dictCacheFileInfo = (Json.Deserialize(text) as Dictionary <string, object>);
         }
         Logger.DEBUG(text);
         if (this.dictCacheFileInfo == null)
         {
             this.dictCacheFileInfo = new Dictionary <string, object>();
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #9
0
        public static void LogCallback(int level, [MarshalAs(20)] string logMsg)
        {
            try
            {
                switch (level)
                {
                case 0:
                    Logger.DEBUG(logMsg);
                    break;

                case 1:
                    Logger.INFO(logMsg);
                    break;

                case 2:
                    Logger.WARN(logMsg);
                    break;

                case 3:
                    Logger.ERROR(logMsg);
                    break;
                }
            }
            catch (Exception var_0_4E)
            {
            }
        }
        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);
        }
Пример #11
0
 public static void AddCommand(Command cmd)
 {
     try
     {
         if (cmd is AddSocketCommand)
         {
             AddSocketCommand addSocketCommand  = cmd as AddSocketCommand;
             long             theUniqueSocketId = addSocketCommand.theUniqueSocketId;
             TCPSocketContext tCPSocketContext  = new TCPSocketContext(addSocketCommand.theUniqueSocketId, addSocketCommand.theHandler);
             if (!NetLib.dictSocketContext.ContainsKey(theUniqueSocketId))
             {
                 Logger.DEBUG(theUniqueSocketId.ToString() + " added");
                 NetLib.dictSocketContext.Add(theUniqueSocketId, tCPSocketContext);
             }
             else
             {
                 TCPSocketContext tCPSocketContext2 = NetLib.dictSocketContext.get_Item(theUniqueSocketId);
                 Logger.ERROR("NetThread::ProcessCommands socket handle conflict " + tCPSocketContext.GetUniqueSocketId().ToString() + " VS " + tCPSocketContext2.GetUniqueSocketId().ToString());
             }
         }
         else if (cmd is SendPacketCommand)
         {
             SendPacketCommand sendPacketCommand = cmd as SendPacketCommand;
             long theUniqueSocketId2             = sendPacketCommand.theUniqueSocketId;
             if (NetLib.dictSocketContext.ContainsKey(theUniqueSocketId2))
             {
                 TCPSocketContext tCPSocketContext3 = NetLib.dictSocketContext.get_Item(theUniqueSocketId2);
                 Packet           packet            = new Packet();
                 packet.theCreateTimeMS = sendPacketCommand.theCreateTimeMS;
                 packet.theContent      = (sendPacketCommand.theContent.Clone() as byte[]);
                 tCPSocketContext3.Enqueue(packet);
                 NetLib.pendingPacketsLength += (long)packet.theContent.Length;
             }
         }
         else
         {
             CloseSocketCommand closeSocketCommand = cmd as CloseSocketCommand;
             long theUniqueSocketId3 = closeSocketCommand.theUniqueSocketId;
             if (NetLib.dictSocketContext.ContainsKey(theUniqueSocketId3))
             {
                 TCPSocketContext tCPSocketContext4 = NetLib.dictSocketContext.get_Item(theUniqueSocketId3);
                 Logger.DEBUG(theUniqueSocketId3.ToString() + " removed");
                 int num = 0;
                 tCPSocketContext4.HandleClose(out num);
                 NetLib.pendingPacketsLength -= (long)num;
                 NetLib.dictSocketContext.Remove(theUniqueSocketId3);
                 NetLib.PandoraNet_Close(theUniqueSocketId3);
             }
             else
             {
                 Logger.WARN("uniqueSocketId=" + theUniqueSocketId3.ToString() + " alreay missing");
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #12
0
 private void TryDoLua(string newReadyAssetBundle)
 {
     try
     {
         Logger.DEBUG(newReadyAssetBundle);
         string text = Utils.GetPlatformDesc() + "_ulua_lua.assetbundle";
         if (this.resMgr.IsLuaAssetBundleLoaded(text) && !this.luaMgrInited)
         {
             LuaStatic.Load     = new ReadLuaFile(this.resMgr.GetLuaBytes);
             this.luaMgr.DoFile = new LuaScriptMgr.FileExecutor(this.DoLoadedLua);
             this.luaMgr.Start();
             this.luaMgrInited = true;
         }
         if (this.luaMgrInited)
         {
             using (Dictionary <string, List <PandoraImpl.FileState> > .Enumerator enumerator = this.dependencyInfos.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     KeyValuePair <string, List <PandoraImpl.FileState> > current = enumerator.get_Current();
                     bool flag = true;
                     using (List <PandoraImpl.FileState> .Enumerator enumerator2 = current.get_Value().GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             PandoraImpl.FileState current2 = enumerator2.get_Current();
                             if (!current2.isReady)
                             {
                                 flag = false;
                             }
                         }
                     }
                     if (flag)
                     {
                         using (List <PandoraImpl.FileState> .Enumerator enumerator3 = current.get_Value().GetEnumerator())
                         {
                             while (enumerator3.MoveNext())
                             {
                                 PandoraImpl.FileState current3 = enumerator3.get_Current();
                                 if (Utils.IsLuaAssetBundle(current3.name) && !current3.name.Equals(text) && !this.executedLuaAssetBundles.Contains(current3.name))
                                 {
                                     Logger.DEBUG(current3.name);
                                     string name = Utils.ExtractLuaName(current3.name);
                                     this.luaMgr.DoFile(name);
                                     this.executedLuaAssetBundles.Add(current3.name);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_Message() + "\n" + ex.get_StackTrace());
     }
 }
Пример #13
0
 public void ProcessBrokerResponse(int status, Dictionary <string, object> content)
 {
     Logger.DEBUG(string.Empty);
     try
     {
         long num = (long)content.get_Item("type");
         if (num == 1L)
         {
             Logger.ERROR("recv invalid type[" + num.ToString() + "] from broker");
         }
         else if (num == 2L)
         {
             int  num2   = (int)((long)content.get_Item("cmd_id"));
             uint callId = (uint)((long)content.get_Item("seq_id"));
             int  num3   = num2;
             if (num3 != 5001)
             {
                 if (num3 != 9000)
                 {
                     Logger.ERROR("recv invalid cmdId[" + num2.ToString() + "] from broker");
                 }
                 else
                 {
                     Logger.DEBUG("recv lua request rsp, seqId[" + callId.ToString() + "]");
                     Dictionary <string, object> dictionary = Json.Deserialize(content.get_Item("body") as string) as Dictionary <string, object>;
                     dictionary.set_Item("netRet", 0);
                     string result = Json.Serialize(dictionary);
                     CSharpInterface.ExecCallback(callId, result);
                 }
             }
             else
             {
                 Logger.DEBUG("recv statistics rsp, seqId[" + callId.ToString() + "]");
                 string json = content.get_Item("body") as string;
                 Dictionary <string, object> dictionary2 = Json.Deserialize(json) as Dictionary <string, object>;
                 int num4 = (int)((long)dictionary2.get_Item("ret"));
                 if (num4 != 0)
                 {
                     Logger.ERROR(string.Concat(new object[]
                     {
                         "recv error statistics rsp, ret[",
                         num4.ToString(),
                         "] errMsg[",
                         dictionary2.get_Item("err_msg")
                     }) + "]");
                 }
             }
         }
         else
         {
             Logger.ERROR("recv invalid type[" + num.ToString() + "] from broker");
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #14
0
        public static Dictionary <string, IPHostEntry> LoadDnsCacheFromFile()
        {
            Dictionary <string, IPHostEntry> dictionary = new Dictionary <string, IPHostEntry>();
            string dnsCacheFileName = Utils.GetDnsCacheFileName();

            try
            {
                if (File.Exists(dnsCacheFileName))
                {
                    string text = File.ReadAllText(dnsCacheFileName);
                    Logger.DEBUG("Dns cache: " + text);
                    Dictionary <string, object> dictionary2 = Json.Deserialize(text) as Dictionary <string, object>;
                    if (dictionary2 != null)
                    {
                        using (Dictionary <string, object> .Enumerator enumerator = dictionary2.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                KeyValuePair <string, object> current = enumerator.get_Current();
                                List <object> list = current.get_Value() as List <object>;
                                if (list != null)
                                {
                                    List <IPAddress> list2 = new List <IPAddress>();
                                    using (List <object> .Enumerator enumerator2 = list.GetEnumerator())
                                    {
                                        while (enumerator2.MoveNext())
                                        {
                                            object    current2  = enumerator2.get_Current();
                                            IPAddress iPAddress = null;
                                            if (IPAddress.TryParse(current2 as string, ref iPAddress))
                                            {
                                                list2.Add(iPAddress);
                                            }
                                        }
                                    }
                                    if (list2.get_Count() > 0)
                                    {
                                        IPHostEntry iPHostEntry = new IPHostEntry();
                                        iPHostEntry.set_AddressList(list2.ToArray());
                                        dictionary.set_Item(current.get_Key(), iPHostEntry);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    Logger.DEBUG("Dns cache file isn't exist");
                }
            }
            catch (Exception ex)
            {
                Logger.ERROR(ex.get_StackTrace());
            }
            return(dictionary);
        }
Пример #15
0
        public void SetBroker(ushort port, string host, string ip1, string ip2)
        {
            Logger.DEBUG(string.Concat(new string[]
            {
                "port=",
                port.ToString(),
                " host=",
                host,
                " ip1=",
                ip1,
                " ip2=",
                ip2
            }));
            this.brokerPort   = port;
            this.brokerHost   = host;
            this.brokerAltIPs = new string[]
            {
                ip1,
                ip2
            };
            Action <IPHostEntry> resultAction = delegate(IPHostEntry entry)
            {
                try
                {
                    Logger.DEBUG(this.brokerHost + " dns done");
                    if (entry != null && entry.get_AddressList().Length > 0)
                    {
                        IPAddress[] addressList = entry.get_AddressList();
                        for (int i = 0; i < addressList.Length; i++)
                        {
                            IPAddress iPAddress = addressList[i];
                            this.brokerIPAddresses.Add(iPAddress);
                        }
                    }
                    else
                    {
                        string[] array = this.brokerAltIPs;
                        for (int j = 0; j < array.Length; j++)
                        {
                            string text = array[j];
                            if (text.get_Length() > 0)
                            {
                                this.brokerIPAddresses.Add(IPAddress.Parse(text));
                            }
                        }
                    }
                    this.lastConnectBrokerTime = 0;
                }
                catch (Exception ex)
                {
                    Logger.ERROR(ex.get_Message() + ": " + ex.get_StackTrace());
                }
            };

            this.AsyncGetHostEntry(this.brokerHost, resultAction);
        }
        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
                {
                    if (!File.Exists(this.tmpFile))
                    {
                        using (FileStream fileStream = File.Create(this.tmpFile))
                        {
                            fileStream.Close();
                        }
                    }
                    FileInfo fileInfo = new FileInfo(this.tmpFile);
                    this.fileSizeBeforeDownload = (int)fileInfo.get_Length();
                    if (this.size != 0 && this.fileSizeBeforeDownload >= this.size)
                    {
                        File.Delete(this.tmpFile);
                        using (FileStream fileStream2 = File.Create(this.tmpFile))
                        {
                            fileStream2.Close();
                            this.fileSizeBeforeDownload = 0;
                        }
                    }
                    Uri    uri  = new Uri(this.url);
                    string text = string.Concat(new string[]
                    {
                        "GET ",
                        uri.get_AbsolutePath(),
                        " HTTP/1.1\r\nHost:",
                        uri.get_Host(),
                        "\r\nAccept:*/*\r\nUser-Agent:Pandora(",
                        Pandora.Instance.GetSDKVersion(),
                        ")\r\nRange:bytes=",
                        this.fileSizeBeforeDownload.ToString(),
                        "-\r\nConnection: keep-alive\r\n\r\n"
                    });
                    Logger.DEBUG(text);
                    byte[] bytes = Encoding.get_UTF8().GetBytes(text);
                    Pandora.Instance.GetNetLogic().SendPacket(uniqueSocketId, bytes);
                }
                catch (Exception ex)
                {
                    Pandora.Instance.GetNetLogic().Close(uniqueSocketId);
                    Logger.ERROR(ex.get_StackTrace());
                }
            };
            Message message = new Message();

            message.status = 0;
            message.action = action;
            Pandora.Instance.GetNetLogic().EnqueueDrive(message);
        }
 public static void SetPosZ(GameObject go, float z)
 {
     try
     {
         go.transform.localPosition = new Vector3(go.transform.localPosition.x, go.transform.localPosition.y, z);
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
 public static void SetScale(GameObject go, float x, float y, float z)
 {
     try
     {
         go.transform.localScale = new Vector3(x, y, z);
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #19
0
 private void FixedUpdate()
 {
     try
     {
         this.luaMgr.FixedUpdate();
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_Message());
     }
 }
Пример #20
0
        private string GetLocationUrl(byte[] receivedData, int dataLen)
        {
            Logger.DEBUG(string.Empty);
            int num  = -1;
            int num2 = -1;
            int num3 = -1;

            for (int i = 0; i < dataLen - DownloadHandler.redirectionField.Length + 1; i++)
            {
                bool flag = true;
                for (int j = 0; j < DownloadHandler.redirectionField.Length; j++)
                {
                    if (receivedData[i + j] != DownloadHandler.redirectionField[j])
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    num = i;
                    break;
                }
            }
            if (num < 0)
            {
                Logger.WARN(string.Empty);
                return(string.Empty);
            }
            for (int k = num + DownloadHandler.redirectionField.Length; k < dataLen; k++)
            {
                if (receivedData[k] != 58 && receivedData[k] != 32 && num2 < 0)
                {
                    num2 = k;
                }
                if (num2 >= 0 && receivedData[k] == 13)
                {
                    num3 = k;
                    break;
                }
            }
            if (num2 < 0 || num3 < 0 || num2 >= num3)
            {
                Logger.ERROR(string.Empty);
                return(string.Empty);
            }
            string @string = Encoding.get_UTF8().GetString(receivedData, num2, num3 - num2);

            Logger.DEBUG(@string);
            return(@string);
        }
Пример #21
0
 public static void DataCallback(int encodedDataLen, [MarshalAs(20)] string encodedData, long uniqueSocketId)
 {
     try
     {
         if (NetLib.dictSocketContext.ContainsKey(uniqueSocketId))
         {
             TCPSocketContext tCPSocketContext = NetLib.dictSocketContext.get_Item(uniqueSocketId);
             tCPSocketContext.ReadDataCallback(encodedDataLen, encodedData);
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #22
0
 public static void NotifyCloseAllPanel()
 {
     try
     {
         LuaScriptMgr luaScriptMgr = Pandora.Instance.GetLuaScriptMgr();
         if (luaScriptMgr != null)
         {
             luaScriptMgr.CallLuaFunction("Common.NotifyCloseAllPanel", new object[0]);
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #23
0
 public void DeleteFile(string fileName)
 {
     try
     {
         this.dictCacheFileInfo.Remove(fileName);
         string text = Json.Serialize(this.dictCacheFileInfo);
         File.WriteAllText(this.cacheMetaFile, text);
         string text2 = Pandora.Instance.GetCachePath() + "/" + fileName;
         File.Delete(text2);
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #24
0
        public static bool WriteCookie(string fileName, string content)
        {
            bool result;

            try
            {
                string text = Pandora.Instance.GetCookiePath() + "/" + fileName;
                File.WriteAllText(text, content);
                result = true;
            }
            catch (Exception ex)
            {
                Logger.ERROR(ex.get_StackTrace());
                result = false;
            }
            return(result);
        }
        private int SplitReceiveDataToPackets()
        {
            int num = 0;

            while (this.receivedLength > 0)
            {
                int num2 = this.theHandler.DetectPacketSize(this.receiveBuffer, this.receivedLength);
                if (num2 > 0)
                {
                    if (num2 > TCPSocketContext.kMaxPakcetSize)
                    {
                        Logger.ERROR("Z1detected packet size overflow " + num2.ToString());
                        return(-1);
                    }
                    this.detectedPacketSize = num2;
                    if (this.detectedPacketSize > this.receivedLength)
                    {
                        return(num);
                    }
                    Packet packet = new Packet();
                    packet.theCreateTimeMS = (long)DateTime.get_Now().get_Millisecond();
                    packet.theContent      = new byte[this.detectedPacketSize];
                    Array.Copy(this.receiveBuffer, 0, packet.theContent, 0, this.detectedPacketSize);
                    this.theHandler.OnReceived(packet);
                    num++;
                    Array.Copy(this.receiveBuffer, this.detectedPacketSize, this.receiveBuffer, 0, this.receivedLength - this.detectedPacketSize);
                    this.receivedLength    -= this.detectedPacketSize;
                    this.detectedPacketSize = 0;
                }
                else
                {
                    if (num2 != 0)
                    {
                        Logger.ERROR("Z3detect packet size error");
                        return(-3);
                    }
                    if (this.receivedLength == TCPSocketContext.kMaxPakcetSize)
                    {
                        Logger.ERROR("Z2format error");
                        return(-2);
                    }
                    break;
                }
            }
            return(num);
        }
Пример #26
0
        public long AsyncConnect(IPAddress address, ushort port, TCPSocketHandler handler)
        {
            Logger.DEBUG("Y1");
            string ipStr = address.ToString();
            long   num   = NetLib.PandoraNet_AsyncConnect(ipStr, port);

            if (num < 0L)
            {
                Logger.ERROR("NetLib.AsyncConnect ret=" + num.ToString());
                return(-1L);
            }
            NetLib.AddCommand(new AddSocketCommand
            {
                theUniqueSocketId = num,
                theHandler        = handler
            });
            return(num);
        }
Пример #27
0
 public void AddCacheFileMeta(string fileName, int fileSize, string fileMD5)
 {
     try
     {
         Dictionary <string, object> dictionary = new Dictionary <string, object>();
         dictionary.set_Item("name", fileName);
         dictionary.set_Item("size", fileSize);
         dictionary.set_Item("md5", fileMD5);
         this.dictCacheFileInfo.set_Item(fileName, dictionary);
         string text = Json.Serialize(this.dictCacheFileInfo);
         Logger.DEBUG(text);
         File.WriteAllText(this.cacheMetaFile, text);
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #28
0
 private void CheckBrokerSession()
 {
     if (this.brokerIPAddresses.get_Count() == 0)
     {
         this.lastConnectBrokerTime = Utils.NowSeconds();
         return;
     }
     try
     {
         Action <int, Dictionary <string, object> > statusChangedAction = delegate(int status, Dictionary <string, object> content)
         {
             this.isBrokerConnecting = false;
             if (status == 0)
             {
                 this.brokerUniqueSocketId = (long)content.get_Item("uniqueSocketId");
             }
             else
             {
                 this.brokerUniqueSocketId = -1L;
                 this.ResetBrokerHeartbeatVars();
             }
         };
         Action <int, Dictionary <string, object> > packetRecvdAction = delegate(int status, Dictionary <string, object> content)
         {
             this.ProcessBrokerResponse(status, content);
         };
         this.lastConnectBrokerTime       = Utils.NowSeconds();
         this.lastTryBorkerIPAddressIndex = (this.lastTryBorkerIPAddressIndex + 1) % this.brokerIPAddresses.get_Count();
         long num = this.SpawnTCPSession(this.brokerIPAddresses.get_Item(this.lastTryBorkerIPAddressIndex), this.brokerPort, new BrokerHandler(statusChangedAction, packetRecvdAction));
         if (num > 0L)
         {
             Logger.DEBUG(this.brokerIPAddresses.get_Item(this.lastTryBorkerIPAddressIndex).ToString());
             this.isBrokerConnecting = true;
         }
         else
         {
             Logger.ERROR(string.Empty);
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #29
0
 public static void NotifyAndroidPayFinish(string jsonData)
 {
     try
     {
         Logger.DEBUG("jsonData=" + jsonData);
         LuaScriptMgr luaScriptMgr = Pandora.Instance.GetLuaScriptMgr();
         if (luaScriptMgr != null)
         {
             luaScriptMgr.CallLuaFunction("Common.NotifyAndroidPayFinish", new object[]
             {
                 jsonData
             });
         }
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }
Пример #30
0
 public void Init()
 {
     try
     {
         this.luaMgr   = new LuaScriptMgr();
         this.resMgr   = new ResourceMgr();
         this.netLogic = new NetLogic();
         this.netLogic.Init();
         Directory.CreateDirectory(Pandora.Instance.GetCachePath());
         Directory.CreateDirectory(Pandora.Instance.GetImgPath());
         Directory.CreateDirectory(Pandora.Instance.GetCookiePath());
         Directory.CreateDirectory(Pandora.Instance.GetLogPath());
         Directory.CreateDirectory(Pandora.Instance.GetTempPath());
     }
     catch (Exception ex)
     {
         Logger.ERROR(ex.get_StackTrace());
     }
 }