Exemplo n.º 1
0
 /// <summary>
 /// Sends the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="token">The token.</param>
 public void Send(ServerSentEvent message, CancellationToken token)
 {
     lock (_syncRoot)
     {
         var closeChannels = new List <IEventChannel>();
         foreach (var channel in _channels)
         {
             try { channel.Send(message, token); }
             catch { closeChannels.Add(channel); }
         }
         foreach (var channel in closeChannels)
         {
             _channels.Remove(channel);
         }
         while (_replayBuffer.Count >= _replayBufferSize)
         {
             _replayBuffer.RemoveAt(0);
         }
         _replayBuffer.Add(message);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Sends the specified sse.
 /// </summary>
 /// <param name="sse">The sse.</param>
 /// <param name="token">The token.</param>
 public void Send(ServerSentEvent sse, CancellationToken token) => Send((object)sse, token);