/// <summary> /// Broadcast a packet to all currently connected peers /// </summary> /// <param name="packet">The packet to be broadcasted</param> public void Broadcast(IPacket packet) { ConnectedPeers.ForEach(x => { lock (_sendLock) { x.Processor.SendPacket(packet, x.NetStream).Wait(); } }); }
protected virtual void Dispose(bool disposing) { if (IsDisposed) { return; } if (disposing) { OnPeerConnected = null; ConnectedPeers.ForEach(p => p.Disconnect()); IsActive = false; ChannelSocket.Close(); } IsDisposed = true; }
/// <summary> /// Broadcasts a message to all peers in this channel /// </summary> /// <param name="data">The packet to broadcast</param> public void Broadcast(IDataPacket data) { ConnectedPeers.ForEach(cp => cp.SendData(data, this, null)); }