예제 #1
0
        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));
        }
예제 #2
0
        public async Task SendRequestAsync(Request request)
        {
            using var cancellationSource = new CancellationTokenSource();
            //cancellationSource.CancelAfter(2000);

            await _webSocketWrapper.SendAsync(request, cancellationSource.Token);
        }
예제 #3
0
        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;
                }
            }
        }
예제 #4
0
        protected override Task SendAsync(WampMessage <object> message)
        {
            ArraySegment <byte> messageToSend = GetMessageInBytes(message);

            return(mWebSocket.SendAsync(messageToSend, WebSocketMessageType, true, mCancellationTokenSource.Token));
        }