private void ProcessPacket(ulong guid, ArraySegment <byte> data) { bool default_id = data.Array[0] < 134; if (default_id) { switch ((RakNetPacketID)data.Array[0]) { case RakNetPacketID.NEW_INCOMING_CONNECTION: connections.Add(new ConnectionInfo(guid, server_peer.GetAddress(guid))); OnConnected(guid); break; case RakNetPacketID.DISCONNECTION_NOTIFICATION: RemoveConnectionByGUID(guid, out ConnectionInfo guid1); OnDisconnected(guid1.guid, DisconnectionType.ConnectionClosed); break; case RakNetPacketID.CONNECTION_LOST: RemoveConnectionByGUID(guid, out ConnectionInfo guid2); OnDisconnected(guid2.guid, DisconnectionType.Timeout); break; } } else { if (GetConnectionByGUID(guid, out int i, out ConnectionInfo connection)) { OnReceivedData(connection.guid, data); connection.packets_received++; } } }