protected override Task SendAsync(WampMessage <object> message) { mLogger.Debug("Attempting to send a message"); ArraySegment <byte> messageToSend = GetMessageInBytes(message); return(mWebSocket.SendAsync(messageToSend, WebSocketMessageType, true, mCancellationToken)); }
public async Task SendRequestAsync(Request request) { using var cancellationSource = new CancellationTokenSource(); //cancellationSource.CancelAfter(2000); await _webSocketWrapper.SendAsync(request, cancellationSource.Token); }
protected override async Task SendAsync(WampMessage <object> message) { mLogger.Debug("Attempting to send a message"); ArraySegment <byte> messageToSend = GetMessageInBytes(message); if (mMaxFrameSize == null) { await mWebSocket.SendAsync(messageToSend, WebSocketMessageType, true, mCancellationToken) .ConfigureAwait(false); } else { int maxFrameSize = mMaxFrameSize.Value; int remainingSize = messageToSend.Count; bool endOfMessage = false; int currentFrameSize = maxFrameSize; int offset = 0; while (remainingSize > 0) { if (remainingSize < maxFrameSize) { endOfMessage = true; currentFrameSize = remainingSize; } ArraySegment <byte> partialMessage = new ArraySegment <byte>(messageToSend.Array, offset, currentFrameSize); await mWebSocket.SendAsync(partialMessage, WebSocketMessageType, endOfMessage, mCancellationToken) .ConfigureAwait(false); offset += maxFrameSize; remainingSize -= maxFrameSize; } } }
protected override Task SendAsync(WampMessage <object> message) { ArraySegment <byte> messageToSend = GetMessageInBytes(message); return(mWebSocket.SendAsync(messageToSend, WebSocketMessageType, true, mCancellationTokenSource.Token)); }