Beispiel #1
0
        private void HandleReceived_Connection(MhfConnection connection, MhfPacket packet)
        {
            if (!_connectionHandlers.ContainsKey(packet.Id))
            {
                //   _logger.LogUnknownIncomingPacket(connection, packet);
                return;
            }

            IConnectionHandler connectionHandler = _connectionHandlers[packet.Id];

            if (connectionHandler.ExpectedSize != NoExpectedSize && packet.Data.Size < connectionHandler.ExpectedSize)
            {
                _logger.Error(connection,
                              $"Ignoring Packed (Id:{packet.Id}) is smaller ({packet.Data.Size}) than expected ({connectionHandler.ExpectedSize})");
                return;
            }

            //  _logger.LogIncomingPacket(connection, packet);
            packet.Data.SetPositionStart();
            try
            {
                connectionHandler.Handle(connection, packet);
            }
            catch (Exception ex)
            {
                _logger.Exception(connection, ex);
            }
        }
Beispiel #2
0
        private void HandleReceived_Connection(NecConnection connection, NecPacket packet)
        {
            if (!_connectionHandlers.ContainsKey(packet.id))
            {
                _Logger.LogUnknownIncomingPacket(connection, packet, _serverType);
                return;
            }

            IConnectionHandler connectionHandler = _connectionHandlers[packet.id];

            if (connectionHandler.expectedSize != NO_EXPECTED_SIZE && packet.data.Size < connectionHandler.expectedSize)
            {
                _Logger.Error(connection,
                              $"[{_serverType}] Ignoring Packed (Id:{packet.id}) is smaller ({packet.data.Size}) than expected ({connectionHandler.expectedSize})");
                return;
            }

            _Logger.LogIncomingPacket(connection, packet, _serverType);
            packet.data.SetPositionStart();
            try
            {
                connectionHandler.Handle(connection, packet);
            }
            catch (Exception ex)
            {
                _Logger.Exception(connection, ex);
            }
        }