public async Task <Message> ReceiveAsync(CancellationToken token)
            {
                if (!_receiveTask.Task.IsCompleted)
                {
                    using (token.Register(() => AsyncReceiveCancelled()))
                    {
                        await _receiveTask.Task;
                    }
                }

                if (_asyncReceiveState == AsyncReceiveState.Cancelled)
                {
                    throw Fx.Exception.AsError(WebSocketHelper.GetTimeoutException(null, TimeoutHelper.GetOriginalTimeout(token), WebSocketHelper.ReceiveOperation));
                }
                else
                {
                    Fx.Assert(_asyncReceiveState == AsyncReceiveState.Finished, "this.asyncReceiveState is not AsyncReceiveState.Finished: " + _asyncReceiveState);
                    Message message = GetPendingMessage();

                    if (message != null)
                    {
                        // If we get any exception thrown out before that, the channel will be aborted thus no need to maintain the receive loop here.
                        StartNextReceiveAsync();
                    }

                    return(message);
                }
            }