/// <summary> /// Safely makes a copy of the list of stream channels. /// </summary> /// <returns>Array containing the stream channels.</returns> public static IEnumerable <WebSocketEventChannel> SafeCopy(this List <WebSocketEventChannel> list) { var channels = new WebSocketEventChannel[list.Count]; list.CopyTo(channels); return(channels); }
/// <summary> /// Handle Http requests for event endpoint. /// </summary> /// <param name="requestContext"> /// Context containing HTTP request data, and which will also contain associated /// response upon return. /// </param> private void HandleEventRequest(HttpListenerContext requestContext) { WebSocketEventChannel.TryOpenAsync( requestContext, channel => this.eventsChannels.Add(channel), channel => this.eventsChannels.Remove(channel)); }