예제 #1
0
 /// <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();
         }
     });
 }
예제 #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (IsDisposed)
     {
         return;
     }
     if (disposing)
     {
         OnPeerConnected = null;
         ConnectedPeers.ForEach(p => p.Disconnect());
         IsActive = false;
         ChannelSocket.Close();
     }
     IsDisposed = true;
 }
예제 #3
0
 /// <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));
 }