Пример #1
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());
     }
 }
Пример #2
0
 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();
         }
     }
 }