protected virtual void OnConnectionReceived(CommunicationStream stream) { try { if (!_connection || !_connection.Established || _connection.Terminated) { return; } _inputStream.SetLength(0); _inputStream.Position = Connection.PacketLengthPos; stream.CopyTo(_inputStream); _inputStream.Position = 0; _packetReader.PreparePacket(); } catch (Exception e) { OnConnectionError($"Protocol.OnConnectionReceived: Failed to prepare packet ({e.Message})."); } }
protected virtual void OnConnectionReceived(ByteArray message) { try { if (!m_Connection || !m_Connection.Established || m_Connection.Terminated) { return; } m_InputBuffer.Position = Connection.PacketLengthPos; m_InputBuffer.Length = 0; m_InputBuffer.WriteBytes(message.Buffer, 0, message.Length); m_InputBuffer.Position = 0; if (!m_PacketReader.PreparePacket()) { OnConnectionError("Protocol.OnConnectionReceived: Failed to prepare packet."); } } catch (Exception) { OnConnectionError("Protocol.OnConnectionReceived: Failed to prepare packet."); } }