internal void DeserializeStream(NetStream stream) { while (NetSerializer.CanReadMessage(stream)) { var message = NetSerializer.ReadNetMessage(stream); if (message == null) { NetLog.Warning("Failed to parse unreliable message from: " + Connection.Endpoint); break; } Connection.Socket.ReceiveMessage(message, Connection); } stream.Release(); }
internal void SerializeMessage(NetMessage message) { if (!NetSerializer.TryWriteMessage(unreliableStream, message)) { if (retry) { NetLog.Warning("SerializeUnreliableMessage failed."); retry = false; return; } // Stream likely full, flush stream and retry serialization: retry = true; FlushStream(); SerializeMessage(message); } if (retry) { retry = false; } }