예제 #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
파일: NetServer.cs 프로젝트: TraeF1337/HKMP
 /**
  * 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
파일: NetServer.cs 프로젝트: TraeF1337/HKMP
 /**
  * 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
파일: NetServer.cs 프로젝트: TraeF1337/HKMP
        /**
         * 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);
 }