private async Task MakeRangeRequest(long startIndex, long endIndex, List <long> channelIds) { MessageHeader header = new MessageHeader(); header.Protocol = (int)Protocols.ChannelStreaming; header.MessageType = 9; header.MessageId = EtpHelper.NextMessageId; header.MessageFlags = 0; header.CorrelationId = 0; ChannelRangeInfo info = new ChannelRangeInfo() { ChannelId = channelIds, StartIndex = startIndex, EndIndex = endIndex }; ChannelRangeRequest requset = new ChannelRangeRequest(); requset.ChannelRanges = new List <ChannelRangeInfo>(); requset.ChannelRanges.Add(info); var data = Encode(requset, header); var buffer = new ArraySegment <byte>(data, 0, data.Length); await m_Socket.SendAsync(buffer, WebSocketMessageType.Binary, true, CancellationToken.None).ConfigureAwait(false); }
/// <summary> /// Handles the channel range request. /// </summary> /// <param name="header">The header.</param> /// <param name="channelRangeRequest">The channel range request.</param> protected override void HandleChannelRangeRequest(IMessageHeader header, ChannelRangeRequest channelRangeRequest) { base.HandleChannelRangeRequest(header, channelRangeRequest); Request = header; if (_tokenSource == null) { _tokenSource = new CancellationTokenSource(); } var token = _tokenSource.Token; Logger.Debug("Channel Range Request starting."); Task.Run(() => StartChannelRangeRequest(channelRangeRequest.ChannelRanges, token), token); }