public async Task StopStreaming() { MessageHeader header = new MessageHeader(); header.Protocol = (int)Protocols.ChannelStreaming; header.MessageType = 5; header.MessageId = EtpHelper.NextMessageId; header.MessageFlags = 0; header.CorrelationId = 0; var channelStreamingStop = new ChannelStreamingStop(); lock (m_ChannelStreamingInfo) { if (m_ChannelStreamingInfo.Count == 0) { return; } channelStreamingStop.Channels = m_ChannelStreamingInfo.Select(x => x.ChannelId).ToList(); m_ChannelStreamingInfo.Clear(); } var data = Encode(channelStreamingStop, header); var buffer = new ArraySegment <byte>(data, 0, data.Length); await m_Socket.SendAsync(buffer, WebSocketMessageType.Binary, true, CancellationToken.None).ConfigureAwait(false); }
protected override void HandleChannelStreamingStop(MessageHeader header, ChannelStreamingStop channelStreamingStop) { base.HandleChannelStreamingStop(header, channelStreamingStop); if (_tokenSource != null) { _tokenSource.Cancel(); } }
/// <summary> /// Handles the channel streaming stop. /// </summary> /// <param name="header">The header.</param> /// <param name="channelStreamingStop">The channel streaming stop.</param> protected override void HandleChannelStreamingStop(IMessageHeader header, ChannelStreamingStop channelStreamingStop) { // no action needed if streaming not in progress if (_tokenSource == null) { this.InvalidState("There are currently no channels streaming.", header.MessageId); return; } StopStreamingChannels(header.MessageId, channelStreamingStop.Channels); base.HandleChannelStreamingStop(header, channelStreamingStop); }
protected override void HandleChannelStreamingStop(IMessageHeader header, ChannelStreamingStop channelStreamingStop) { base.HandleChannelStreamingStop(header, channelStreamingStop); _tokenSource?.Cancel(); }