public void OnServerPacket(byte[] inValue)
        {
            LibCommon.Network.Types.GameMessage msg = new LibCommon.Network.Types.GameMessage();

            ThriftMessageSerialize.DeSerializeCompact(msg, inValue);
            ClientQueue.Enqueue(msg);
        }
        public override void SendCommandRemote(QueueType inQueue,
                                               LibCommon.Network.Types.GameMessage inEvent)
        {
            byte[] msg = ThriftMessageSerialize.SerializeCompact(inEvent);

            if (inQueue == QueueType.Client)
            {
                if (string.IsNullOrEmpty(inEvent.NetworkId))
                {
                    //_internalNetwork.BroadcastAll(NetworkUtils.SerializeEvent(inEvent));

                    _internalNetwork.BroadcastAll(msg);

                    ClientQueue.Enqueue(inEvent);
                }
                else
                {
                    Debug.Log(inEvent.NetworkId);

                    if (inEvent.NetworkId == "-1")
                    {
                        ClientQueue.Enqueue(inEvent);
                    }
                    else
                    {
                        _internalNetwork.SendPacketToClient(inEvent.NetworkId, msg);
                    }
                }
            }
            else
            {
                _internalNetwork.SendToServer(msg);
            }
        }
        public void OnClientPacket(byte[] inValue, string inId)
        {
            LibCommon.Network.Types.GameMessage msg = new LibCommon.Network.Types.GameMessage();
            ThriftMessageSerialize.DeSerializeCompact(msg, inValue);

            msg.NetworkId = inId;

            ServerQueue.Enqueue(msg);
        }
        public override void SendCommandRemote(QueueType inQueue,
                                               LibCommon.Network.Types.GameMessage inEvent)
        {
            byte[] msg = ThriftMessageSerialize.SerializeCompact(inEvent);

            if (inQueue == QueueType.Client)
            {
                ClientQueue.Enqueue(inEvent);
            }
            else
            {
                _internalNetwork.SendToServer(msg);
            }
        }
示例#5
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);
            }
        }
示例#6
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;
        }