public string CallGame(uint callId, LuaTable luatable) { string result2 = string.Empty; if (string.IsNullOrEmpty(luatable["type"].ToString())) { return(result2); } Logger.DEBUG(string.Concat(new object[] { "callId=", callId.ToString(), " type=", luatable["type"] })); Action <string> action = delegate(string result) { CSharpInterface.ExecCallback(callId, result); }; Dictionary <string, object> dictionary = new Dictionary <string, object>(); using (IDictionaryEnumerator enumerator = luatable.GetEnumerator()) { while (enumerator.MoveNext()) { DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.get_Current(); dictionary.Add(dictionaryEntry.get_Key().ToString(), dictionaryEntry.get_Value()); } } if (this.callbackForCallGame != null) { result2 = this.callbackForCallGame.Invoke(dictionary, action); } return(result2); }
public void ReadDataCallback(int encodedDataLen, string encodedData) { Logger.DEBUG("theUniqueSocketId=" + this.theUniqueSocketId.ToString() + " encodedDataLen=" + encodedDataLen.ToString()); byte[] array = Convert.FromBase64String(encodedData); Logger.DEBUG("decodedData.Length=[" + array.Length + "]"); Array.Copy(array, 0, this.receiveBuffer, this.receivedLength, array.Length); }
private void TrySendBrokerRequest() { if (this.brokerUniqueSocketId > 0L) { while (this.brokerPendingRequests.get_Count() > 0) { Logger.DEBUG(string.Empty); PendingRequest pendingRequest = this.brokerPendingRequests.Dequeue() as PendingRequest; this.netFrame.SendPacket(this.brokerUniqueSocketId, pendingRequest.data); } } else { int num = Utils.NowSeconds(); while (this.brokerPendingRequests.get_Count() > 0) { PendingRequest pendingRequest2 = this.brokerPendingRequests.Peek() as PendingRequest; if (num <= pendingRequest2.createTime + 5) { break; } Logger.WARN(string.Empty); this.brokerPendingRequests.Dequeue(); } } }
public void Assgin(Dictionary <string, string> dictPara) { Logger.DEBUG(string.Empty); if (dictPara.ContainsKey("sRoleId")) { this.sRoleId = dictPara.get_Item("sRoleId"); } if (dictPara.ContainsKey("sOpenId")) { this.sOpenId = dictPara.get_Item("sOpenId"); } if (dictPara.ContainsKey("sServiceType")) { this.sServiceType = dictPara.get_Item("sServiceType"); } if (dictPara.ContainsKey("sAcountType")) { this.sAcountType = dictPara.get_Item("sAcountType"); } if (dictPara.ContainsKey("sArea")) { this.sArea = dictPara.get_Item("sArea"); } if (dictPara.ContainsKey("sPartition")) { this.sPartition = dictPara.get_Item("sPartition"); } if (dictPara.ContainsKey("sAppId")) { this.sAppId = dictPara.get_Item("sAppId"); } if (dictPara.ContainsKey("sAccessToken")) { this.sAccessToken = dictPara.get_Item("sAccessToken"); } if (dictPara.ContainsKey("sPayToken")) { this.sPayToken = dictPara.get_Item("sPayToken"); } if (dictPara.ContainsKey("sGameVer")) { this.sGameVer = dictPara.get_Item("sGameVer"); } if (dictPara.ContainsKey("sPlatID")) { this.sPlatID = dictPara.get_Item("sPlatID"); } if (dictPara.ContainsKey("sQQInstalled")) { this.sQQInstalled = dictPara.get_Item("sQQInstalled"); } if (dictPara.ContainsKey("sWXInstalled")) { this.sWXInstalled = dictPara.get_Item("sWXInstalled"); } if (dictPara.ContainsKey("sGameName")) { this.sGameName = dictPara.get_Item("sGameName"); } }
public void Logout() { Logger.DEBUG(string.Empty); this.netFrame.Reset(); this.resultQueue.Clear(); this.isDownloadingPaused = false; this.atmIPAddresses.Clear(); this.lastTryAtmIPAddressIndex = 0; this.atmUniqueSocketId = -1L; this.lastConnectAtmTime = -1; this.isAtmConnecting = false; this.atmPendingRequests.Clear(); this.brokerPort = 0; this.brokerHost = string.Empty; this.brokerAltIPs = new string[0]; this.brokerIPAddresses.Clear(); this.lastTryBorkerIPAddressIndex = 0; this.brokerUniqueSocketId = -1L; this.lastConnectBrokerTime = -1; this.isBrokerConnecting = false; this.brokerPendingRequests.Clear(); this.ResetBrokerHeartbeatVars(); this.downloadRequestQueue.Clear(); this.logicDriveQueue.Clear(); }
public override void OnEndDrag(PointerEventData eventData) { Logger.DEBUG("end of a drag"); if (this.onEndDrag == null) { return; } RectTransform rectTransform = base.gameObject.transform as RectTransform; GameObject gameObject = base.gameObject.transform.GetChild(0).gameObject; RectTransform rectTransform2 = gameObject.transform as RectTransform; if (rectTransform == null || rectTransform2 == null) { return; } float height = rectTransform.rect.height; float height2 = rectTransform2.rect.height; float y = rectTransform2.anchoredPosition.y; Logger.DEBUG(string.Format("{0:G},{1:G},{2:G}", height, height2, y)); float num = (height2 - height > 0f) ? (height2 - height) : 0f; if (y - num > 20f) { Logger.DEBUG("should refresh and do callback"); if (this.onEndDrag != null) { this.onEndDrag(base.gameObject); } } }
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()); } }
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()); } }
public static void DestroyPanel(string panelName) { Logger.DEBUG("panelName=" + panelName); PandoraImpl pandoraImpl = Pandora.Instance.GetPandoraImpl(); pandoraImpl.DestroyPanel(panelName); }
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()); } }
public static void AsyncDownloadImage(string url) { Logger.DEBUG(url); PandoraImpl pandoraImpl = Pandora.Instance.GetPandoraImpl(); pandoraImpl.ShowIMG(string.Empty, url, null, 0u); }
public int HandleClose(out int discardDataSize) { Logger.DEBUG("Z12"); discardDataSize = 0; IEnumerator enumerator = this.pendingPackets.GetEnumerator(); try { while (enumerator.MoveNext()) { Packet packet = (Packet)enumerator.get_Current(); discardDataSize += packet.theContent.Length; } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } this.pendingPackets.Clear(); this.theHandler.OnClose(); return(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); }
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) { } }
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"); } } }
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()); } }
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()); } }
public void Drive() { if (this.isDownloadingPaused) { return; } this.netFrame.Drive(); while (this.resultQueue.get_Count() > 0) { Message message = this.resultQueue.Dequeue() as Message; if (message.action != null) { message.action.Invoke(message.status, message.content); } } int num = Utils.NowSeconds(); if (this.atmUniqueSocketId < 0L && !this.isAtmConnecting && this.lastConnectAtmTime + 5 < num) { this.CheckAtmSession(); } if (this.brokerUniqueSocketId < 0L && !this.isBrokerConnecting && this.lastConnectBrokerTime + 5 < num) { this.CheckBrokerSession(); } this.TrySendAtmReport(); this.TrySendBrokerRequest(); while (this.logicDriveQueue.get_Count() > 0) { Message message2 = this.logicDriveQueue.Dequeue() as Message; if (message2.action != null) { message2.action.Invoke(message2.status, message2.content); } } while (this.downloadRequestQueue.get_Count() > 0) { NetLogic.DownloadRequest request = this.downloadRequestQueue.Dequeue() as NetLogic.DownloadRequest; Action <int, Dictionary <string, object> > action = delegate(int downloadRet, Dictionary <string, object> content) { if (downloadRet == 100) { Logger.DEBUG(string.Empty); string url = content.get_Item("locationUrl") as string; this.AddDownload(url, request.size, request.md5, request.destFile, request.curRedirectionTimes + 1, request.action); } else { Logger.DEBUG(string.Empty); Message message3 = new Message(); message3.status = downloadRet; message3.action = request.action; message3.content = content; this.EnqueueResult(message3); } }; this.DownloadFile(request.url, request.size, request.md5, request.destFile, request.curRedirectionTimes, action); } }
public void CallGame(Dictionary <string, string> cmdDict) { Logger.DEBUG(string.Empty); if (this.callbackForGame != null) { this.callbackForGame.Invoke(cmdDict); } }
private void OnApplicationQuit() { Logger.DEBUG(string.Empty); if (this.netLogic != null) { this.netLogic.Destroy(); } }
private void SendLoginToBroker() { string brokerLoginReq = this.GetBrokerLoginReq(); Logger.DEBUG("Send login request to broker, req=" + brokerLoginReq); this.CallBroker(this.brokerHeartbeatSeqNo++, brokerLoginReq, 1001, 1, 10); this.lastSendBrokerHeartbeatReqTime = Utils.NowSeconds(); }
public void Close(long uniqueSocketId) { Logger.DEBUG("Y5" + uniqueSocketId.ToString()); NetLib.AddCommand(new CloseSocketCommand { theUniqueSocketId = uniqueSocketId }); }
public void CloseAllPanel() { Logger.DEBUG(string.Empty); if (this.pandoraImpl != null) { this.pandoraImpl.CloseAllPanel(); } }
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()); } }
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()); } }
public void CloseAllPanel() { Logger.DEBUG(string.Empty); if (this.luaMgrInited) { Logger.DEBUG(string.Empty); CSharpInterface.NotifyCloseAllPanel(); } }
public void SetPandoraParent(GameObject thePandoraParent) { Logger.DEBUG(string.Empty); this.pandoraParent = thePandoraParent; if (this.pandoraGameObject != null) { this.pandoraGameObject.transform.parent = this.pandoraParent.transform; } }
public void Logout() { Logger.DEBUG(string.Empty); this.userData.Clear(); if (this.pandoraImpl != null) { this.pandoraImpl.LogOut(); } }
public override void OnClose() { Logger.DEBUG(string.Empty); Message message = new Message(); message.status = -1; message.action = this.theAction; Pandora.Instance.GetNetLogic().EnqueueResult(message); }
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); }