示例#1
0
        protected override void SendPacket(Packet.Packet packet)
        {
            if (!UdpClient.Client.Connected)
            {
                return;
            }

            UdpClient.BeginSend(packet.ToArray(), packet.Length(), _endPoint, null, null);
        }
示例#2
0
        /// <inheritdoc />
        protected override void SendPacket(Packet.Packet packet)
        {
            if (!UdpClient.Client.Connected)
            {
                return;
            }

            UdpClient.Send(packet.ToArray(), packet.Length);
        }
示例#3
0
 /**
  * Sends a packet to all connected clients over UDP
  */
 private void BroadcastUdp(Packet.Packet packet)
 {
     foreach (var client in _clients.Values)
     {
         // Make sure that we use a clean packet object every time
         var newPacket = new Packet.Packet(packet.ToArray());
         // Send the newly constructed packet to the client
         client.SendUdp(_udpClient, newPacket);
     }
 }
示例#4
0
 /**
  * Sends a packet to all connected clients over TCP
  */
 public void BroadcastTcp(Packet.Packet packet)
 {
     foreach (var idClientPair in _clients)
     {
         // Make sure that we use a clean packet object every time
         var newPacket = new Packet.Packet(packet.ToArray());
         // Send the newly constructed packet to the client
         idClientPair.Value.SendTcp(newPacket);
     }
 }
示例#5
0
        /**
         * Sends a packet to the client with the given ID over UDP
         */
        private void SendUdp(ushort id, Packet.Packet packet)
        {
            if (!_clients.ContainsKey(id))
            {
                Logger.Info(this, $"Could not find ID {id} in clients, could not send UDP packet");
                return;
            }

            // Make sure that we use a clean packet object every time
            var newPacket = new Packet.Packet(packet.ToArray());

            // Send the newly constructed packet to the client
            _clients[id].SendUdp(_udpClient, newPacket);
        }
示例#6
0
        public void Send(Packet.Packet packet)
        {
            if (UdpClient?.Client == null)
            {
                return;
            }

            if (!UdpClient.Client.Connected)
            {
                Logger.Get().Error(this, "Tried sending packet, but UDP was not connected");
                return;
            }

            // Send the packet
            UdpClient.BeginSend(packet.ToArray(), packet.Length(), null, null);
        }
示例#7
0
 /**
  * Sends a packet over UDP to this specific client
  */
 public void SendUdp(UdpClient udpClient, Packet.Packet packet)
 {
     udpClient.BeginSend(packet.ToArray(), packet.Length(), _endPoint, null, null);
 }
示例#8
0
 /// <inheritdoc />
 protected override void SendPacket(Packet.Packet packet)
 {
     UdpClient.Send(packet.ToArray(), packet.Length, _endPoint);
 }