示例#1
0
        // Note:  This is called from the read thread without sync context
        public void ReceiveMessageBuffer(ISocket readingSocket, EndPoint messageSender, BMSByte buffer)
        {
            IMessageConstructor constructor = MessageBufferInterpreter.ReconstructPacketPage(buffer, messageSender);

            if (constructor.MessageReconstructed)
            {
                try
                {
                    var m = (IMessage)ForgeMessageCodes.Instantiate(constructor.MessageBuffer.GetBasicType <int>());
                    ProcessMessageSignature(readingSocket, messageSender, constructor.MessageBuffer, m);

                    if (m.Receipt != null)
                    {
                        if (_storedMessages.Exists(messageSender, m.Receipt))
                        {
                            return;
                        }
                        _storedMessages.AddMessage(m, messageSender, _networkMediator.PlayerTimeout);
                    }

                    m.Deserialize(constructor.MessageBuffer);
                    var interpreter = m.Interpreter;
                    if (interpreter != null)
                    {
                        _synchronizationContext.Post(InterpretWithinContext, new SocketContainerSynchronizationReadData
                        {
                            Interpreter = interpreter,
                            Sender      = messageSender,
                            Message     = m
                        });
                    }
                }
                catch (MessageCodeNotFoundException ex)
                {
                    _networkMediator.EngineProxy.Logger.LogException(ex);
                }
                MessageBufferInterpreter.Release(constructor);
            }
        }
示例#2
0
 private static int GetMessageCode(IMessage message)
 {
     return(ForgeMessageCodes.GetCodeFromType(message.GetType()));
 }