Exemple #1
0
        public override void SendCommandRemote(QueueType inQueue, LibCommon.Network.Types.GameMessage inMsg)
        {
            string msg = ThriftMessageSerialize.Serialize(inMsg);

            if (inQueue == QueueType.Client)
            {
                ClientQueue.Enqueue(inMsg);
            }
            else
            {
                _wwwSendMessageRequest.PostData = Encoding.UTF8.GetBytes(msg);
                AssetManager.Instance.RequestAssetLoad(_wwwSendMessageRequest);
            }
        }
Exemple #2
0
 public override void SendCommandLocal(QueueType inQueue, LibCommon.Network.Types.GameMessage inMsg)
 {
     if (inQueue == QueueType.Client)
     {
         ClientQueue.Enqueue(inMsg);
     }
     else
     {
         if (inQueue == QueueType.Server)
         {
             ServerQueue.Enqueue(inMsg);
         }
     }
 }
Exemple #3
0
        public override LibCommon.Network.Types.GameMessage PopCommand(QueueType inQueue)
        {
            LibCommon.Network.Types.GameMessage ee = null;
            if (inQueue == QueueType.Client)
            {
                ee = ClientQueue.Dequeue();
            }
            else
            {
                if (inQueue == QueueType.Server)
                {
                    ee = ServerQueue.Dequeue();
                }
            }

            return(ee);
        }
Exemple #4
0
        public void OnServerPacker(AssetLoadRequest inValue)
        {
            if (!_running)
            {
                return;
            }

            if (!inValue.HasFailed)
            {
                AsyncPollingWebLoader asyncPollingWebLoader = inValue as AsyncPollingWebLoader;
                byte[] jsonData = asyncPollingWebLoader?.WebData;

                if (jsonData != null)
                {
                    string jsonString = Encoding.UTF8.GetString(jsonData);
                    try
                    {
                        GameMessageList mm = new GameMessageList();
                        ThriftMessageSerialize.DeSerialize(mm, jsonString);

                        foreach (string item in mm.Messages)
                        {
                            LibCommon.Network.Types.GameMessage gm = new LibCommon.Network.Types.GameMessage();
                            ThriftMessageSerialize.DeSerialize(gm, item);

                            ClientQueue.Enqueue(gm);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.LogErrorFormat("Error Message: {0} {1}", ex.Message, jsonString);
                    }
                }
            }

            _requestingCurrently = false;
        }