private void Send() { BasePacket[] packetList = PrepPacketsToSend(); if (packetList == null) { return; } memoryStream.Seek(0, SeekOrigin.Begin); for (int i = 0; i < packetList.Length; i++) { BasePacket packet = packetList[i]; ManageDebuggingPackets(packet); int pos = Network.Utils.SetupWrite(binaryWriter); packet.Write(binaryWriter); Network.Utils.FinishWrite(binaryWriter, pos); IntrepidSerialize.ReturnToPool(packet); } SendRecursive(packetList); }
public bool ProcessIdPackets()// TODO: only process id packets { List <BasePacket> packets = RetrieveData(); if (packets.Count == 0) { // We're still waiting for their packet return(true); } else if (packets.Count == 1) { BasePacket packet = packets[0]; ServerIdPacket id = packet as ServerIdPacket; if (id != null) { gameId = id.Id; serverType = id.Type; int mapId = id.MapId; versionAndHandshakeComplete = true; IntrepidSerialize.ReturnToPool(packet); return(true); } /* if (packet is ServerPingHopperPacket) * { * HandleServerHopping(packet as ServerPingHopperPacket); * return true; * }*/ IntrepidSerialize.ReturnToPool(packet); } // If we're here, it means we either received more than one packet // or it wasn't a ServerIdPacket, which means the server isn't behaving // properly return(false); }