public void SaveMessageToSend(byte[] message, IPEndPoint ip) { IPDataPacket ipDataPacket = new IPDataPacket(ip, message); messagesToSend.Enqueue(ipDataPacket); messagesNotAcked[message[0]] = ipDataPacket; }
public void SaveMessageToSend(byte[] message, IPEndPoint ip) { IPDataPacket ipDataPacket = new IPDataPacket(ip, message); if (message.Length > 1) { messagesNotAcked[message[0]] = ipDataPacket; } else { acksToSend.Enqueue(ipDataPacket); } }
public void SaveReceivedData(IPDataPacket data) { byte[] message = data.message; byte packetId = message[0]; if (!messagesAcked.ContainsKey(data.ip)) { messagesAcked[data.ip] = new byte[byte.MaxValue]; } switch (message[1]) { case (byte)RSSPacketTypes.SPAWNED_PLAYER: if (messagesAcked[data.ip][packetId] != MESSAGE_IS_ACKED) { messagesAcked[data.ip][packetId] = MESSAGE_IS_ACKED; EnqueueGottenMessage(new [] { message[1], message[2] }, packetId, data.ip); } break; case (byte)RSSPacketTypes.INIT_CONNECTION: if (messagesAcked[data.ip][packetId] != MESSAGE_IS_ACKED) { messagesAcked[data.ip][packetId] = MESSAGE_IS_ACKED; EnqueueGottenMessage(new [] { message[2] }, packetId, data.ip); } break; case (byte)RSSPacketTypes.DESTROY_OBJECT: case (byte)RSSPacketTypes.CREATE_OBJECT: if (messagesAcked[data.ip][packetId] != MESSAGE_IS_ACKED) { messagesAcked[data.ip][packetId] = MESSAGE_IS_ACKED; EnqueueGottenMessage(new [] { message[1], message[2], message[3] }, packetId, data.ip); } break; case (byte)RSSPacketTypes.ACK: messagesNotAcked.Remove(packetId); break; } }
public void SaveReceivedData(IPDataPacket data) { byte[] message = data.message; byte packetId = message[0]; if (message.Length == 1) { messagesNotAcked.Remove(packetId); } else { if (!messagesAcked.ContainsKey(data.ip)) { messagesAcked[data.ip] = byte.MaxValue; } SendAck(packetId, data.ip); if (messagesAcked[data.ip] < packetId || (messagesAcked[data.ip] > 250 && packetId < 5)) { byte[] decapsulatedMessage = { message[1], message[2] }; messagesToReceive.Enqueue(new IPDataPacket(data.ip, decapsulatedMessage)); messagesAcked[data.ip] = packetId; } } }
public void SaveReceivedData(IPDataPacket data) { messagesToReceive.Enqueue(data); }