Esempio n. 1
0
        private void DispatchEntityNetworkMessage(MsgEntity message)
        {
            // Don't try to retrieve the session if the client disconnected
            if (!message.MsgChannel.IsConnected)
            {
                return;
            }

            var player = _playerManager.GetSessionByChannel(message.MsgChannel);

            if (message.Sequence != 0)
            {
                if (_lastProcessedSequencesCmd[player] < message.Sequence)
                {
                    _lastProcessedSequencesCmd[player] = message.Sequence;
                }
            }

            switch (message.Type)
            {
            case EntityMessageType.ComponentMessage:
                ReceivedComponentMessage?.Invoke(this, new NetworkComponentMessage(message, player));
                return;

            case EntityMessageType.SystemMessage:
                var msg         = message.SystemMessage;
                var sessionType = typeof(EntitySessionMessage <>).MakeGenericType(msg.GetType());
                var sessionMsg  = Activator.CreateInstance(sessionType, new EntitySessionEventArgs(player), msg) !;
                ReceivedSystemMessage?.Invoke(this, sessionMsg);
                return;
            }
        }
Esempio n. 2
0
        private void HandleEntityNetworkMessage(MsgEntity message)
        {
            switch (message.Type)
            {
            case EntityMessageType.ComponentMessage:
                ReceivedComponentMessage?.Invoke(this, new NetworkComponentMessage(message));
                return;

            case EntityMessageType.SystemMessage:
                ReceivedSystemMessage?.Invoke(this, message.SystemMessage);
                return;
            }
        }