/// <summary> /// Sends provided packet by ip and mac address which is set in packet /// </summary> /// <param name="packet">Packet to send</param> /// <param name="countToSend">Count to send</param> public void SendPacket(INewPacket packet, int countToSend, int timeToWaitUntilNextPacketSend) { if (packet is null) { throw new ArgumentNullException(nameof(packet)); } _packetSender.SendPacket(packet, countToSend, timeToWaitUntilNextPacketSend); }
public void Init() { var cmd = String.Format("START:"); Logger.Instance.Debug(this, "send", cmd); lock (lockObj) { Logger.Instance.Debug(this, "lock", "success"); try { output.SendPacket(cmd); } catch (Exception e) { Logger.Instance.Error(this, "send", e.ToString()); } } }
private async void BroadcastKeepAliveMessages(object state) { foreach (var peer in _peerTracker.GetAllTrackedPeers()) { var randomSetOfPeers = _peerTracker.GetRandomSetOfTrackedPeers(8); var keepAliveMessage = new KeepAliveMessage(_messageHeader); keepAliveMessage.Peers = randomSetOfPeers.Select(x => x.IpEndPoint).ToArray(); await _packetSender.SendPacket(keepAliveMessage, peer.IpEndPoint); } }