예제 #1
0
 /// <summary>
 /// Raise message event.
 /// </summary>
 /// <param name="args"></param>
 private void RaiseMessageEvent(WebSocketClientMessageEventArgs args)
 {
     try { Message?.Invoke(this, args); }
     catch (OperationCanceledException) { }
     catch (Exception e)
     {
         _logger?.LogError(e, $"{nameof(WebSocketClient)}: Unhandled message event handler exception.");
     }
 }
예제 #2
0
        private void OnClientMessage(object sender, WebSocketClientMessageEventArgs e)
        {
            // Provides buffering and single-threaded execution.
            BufferBlock.Post(e.Message);

            var count = BufferBlock.Count;

            if (count <= _maxBufferCount)
            {
                return;
            }

            _maxBufferCount = count;
            if (_maxBufferCount > 1)
            {
                Logger?.LogTrace($"{GetType().Name} - Maximum buffer block count: {_maxBufferCount}");
            }
        }