/// <summary> /// Sends a packet to the server /// </summary> /// <param name="packet">The packet to send, usually the InputState</param> public void SendPacket(Packet.Packet packet) { var packetBytes = packet.Serialize(); //UdpClient.Send(packetBytes, packetBytes.Length); UdpClient.BeginSend(packetBytes, packetBytes.Length, SentData, UdpClient); }
/// <summary> /// Serializes a packet and sends it over the wire to a client /// </summary> /// <param name="packet">The packet to convert to serialized bytes</param> /// <param name="sender">The remote client to send the data to</param> public void SendData(Packet.Packet packet, IPEndPoint sender) { var responseBytes = packet.Serialize(); UdpServer.BeginSend(responseBytes, responseBytes.Length, sender, SentCallback, UdpServer); }