private void Channel_ConnectionEnded(IQueuingReliableCometTransport sender, EventArgs e) { bool triggerEvent = false; using (TimedLock.Lock(ChannelsInt)) if (ChannelsInt.Contains(sender)) { triggerEvent = true; ChannelsInt.Remove(sender); } if ((null != ClientDisconnected) && triggerEvent) ClientDisconnected(this, new EventArgs<IQueuingReliableCometTransport>(sender)); }
private void Channel_DataRecieved(IQueuingReliableCometTransport sender, EventArgs<QueuingReliableCometTransport.Packet> e) { DataReceivedEventArgs drea = new DataReceivedEventArgs(); drea._Data = e.Value._Data; drea._Transport = sender; if (null != DataReceived) DataReceived(this, drea); }
/// <summary> /// Adds a QueuingReliableCometTransport /// </summary> /// <param name="channel"> /// A <see cref="IQueuingReliableCometTransport"/> /// </param> public void AddChannel(IQueuingReliableCometTransport channel) { using (TimedLock.Lock(ChannelsInt)) { ChannelsInt.Add(channel); channel.DataRecieved += new EventHandler<IQueuingReliableCometTransport, EventArgs<QueuingReliableCometTransport.Packet>>(Channel_DataRecieved); channel.ConnectionDisconnecting += new EventHandler<IQueuingReliableCometTransport, EventArgs>(Channel_ConnectionEnded); channel.ConnectionEnded += new EventHandler<IQueuingReliableCometTransport, EventArgs>(Channel_ConnectionEnded); } if (null != ClientConnected) ClientConnected(this, new EventArgs<IQueuingReliableCometTransport>(channel)); }