public void SendPlayerDisconnect() { var packet = Packet.Obtain(); ClientSerializationManager.SerializePlayerDisconnect(packet.buffer); packet.buffer.Flush(); channel.Send(packet, serverIpEndPoint); packet.Free(); }
private void SendPlayerJoinedAck(int newPlayerId) { var packet = Packet.Obtain(); ClientSerializationManager.SerializePlayerJoinedAck(packet.buffer, newPlayerId, clientId); packet.buffer.Flush(); channel.Send(packet, serverIpEndPoint); packet.Free(); }
// Serialize & send commands to server private void SendCommands(List <Commands> commandsList) { var packet = Packet.Obtain(); ClientSerializationManager.SerializeCommands(packet.buffer, commandsList, clientId); packet.buffer.Flush(); if (latency != 0) { Task.Delay(latency).ContinueWith(t => channel.Send(packet, serverIpEndPoint)).ContinueWith(t => packet.Free()); } else { channel.Send(packet, serverIpEndPoint); packet.Free(); } }
public void SendPlayerShotMessage(int shotPlayerId) { unAckedShots.Add(new Shot(shotSeq, shotPlayerId)); shotSeq++; var packet = Packet.Obtain(); ClientSerializationManager.SerializePlayerShot(packet.buffer, unAckedShots, clientId); packet.buffer.Flush(); if (latency != 0) { Task.Delay(latency).ContinueWith(t => channel.Send(packet, serverIpEndPoint)).ContinueWith(t => packet.Free()); } else { channel.Send(packet, serverIpEndPoint); packet.Free(); } }