void ProcessMessagePart(ref Header header, byte[] payload, int len) { if (!OngoingMessages.TryGetValue(header.ID, out OngoingMessage mes)) { mes = new OngoingMessage(header.Channel, header.TotalParts, header.Length, header.ID); OngoingMessages.Add(mes.ID, mes); } if (!mes.partsCollected[header.Part]) { MessagePart part = MessagePart.Desserialize(payload, len); bool finished = mes.MessageRecieved(part, MaxPacketSize); if (finished) { ProcessData(mes.Data, mes.Data.Length); OngoingMessages.Remove(mes.ID); } } Send(new MessagePartConfirmation(header.ID, header.Part)); }