public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { if ("ConnectionConsumer".Equals(oobCtrlMsg.Target)) { if ("pendingCount".Equals(oobCtrlMsg.ServiceName)) { oobCtrlMsg.Result = this._connection.PendingMessages; } else if ("pendingVideoCount".Equals(oobCtrlMsg.ServiceName)) { IClientStream streamByChannelId = null; if (this._connection is IStreamCapableConnection) { streamByChannelId = (this._connection as IStreamCapableConnection).GetStreamByChannelId(this._video.ChannelId); } if (streamByChannelId != null) { oobCtrlMsg.Result = this._connection.GetPendingVideoMessages(streamByChannelId.StreamId); } else { oobCtrlMsg.Result = 0L; } } else if ("writeDelta".Equals(oobCtrlMsg.ServiceName)) { long num = 0L; IBWControllable parentBWControllable = this._connection as IBWControllable; while ((parentBWControllable != null) && (parentBWControllable.BandwidthConfiguration == null)) { parentBWControllable = parentBWControllable.GetParentBWControllable(); } if ((parentBWControllable != null) && (parentBWControllable.BandwidthConfiguration != null)) { IBandwidthConfigure bandwidthConfiguration = parentBWControllable.BandwidthConfiguration; if (bandwidthConfiguration is IConnectionBWConfig) { num = (bandwidthConfiguration as IConnectionBWConfig).DownstreamBandwidth / 8L; } } if (num <= 0L) { num = 0x1e000L; } oobCtrlMsg.Result = new long[] { this._connection.WrittenBytes - this._connection.ClientBytesRead, num / 2L }; } else if ("chunkSize".Equals(oobCtrlMsg.ServiceName)) { int num2 = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"]; if (num2 != this._chunkSize) { this._chunkSize = num2; ChunkSize message = new ChunkSize(this._chunkSize); this._connection.GetChannel(2).Write(message); } } } }
public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { if (!"ConnectionConsumer".Equals(oobCtrlMsg.Target)) { return; } if ("pendingCount".Equals(oobCtrlMsg.ServiceName)) { oobCtrlMsg.Result = _connection.PendingMessages; } else if ("pendingVideoCount".Equals(oobCtrlMsg.ServiceName)) { IClientStream stream = null; if (_connection is IStreamCapableConnection) { stream = (_connection as IStreamCapableConnection).GetStreamByChannelId(_video.ChannelId); } if (stream != null) { oobCtrlMsg.Result = _connection.GetPendingVideoMessages(stream.StreamId); } else { oobCtrlMsg.Result = (long)0; } } else if ("writeDelta".Equals(oobCtrlMsg.ServiceName)) { long maxStream = 0; IBWControllable bwControllable = _connection as IBWControllable; // Search FC containing valid BWC while (bwControllable != null && bwControllable.BandwidthConfiguration == null) { bwControllable = bwControllable.GetParentBWControllable(); } if (bwControllable != null && bwControllable.BandwidthConfiguration != null) { IBandwidthConfigure bwc = bwControllable.BandwidthConfiguration; if (bwc is IConnectionBWConfig) { maxStream = (bwc as IConnectionBWConfig).DownstreamBandwidth / 8; } } if (maxStream <= 0) { // Use default value // TODO: this should be configured somewhere and sent to the client when connecting maxStream = 120 * 1024; } // Return the current delta between sent bytes and bytes the client // reported to have received, and the interval the client should use // for generating BytesRead messages (half of the allowed bandwidth). oobCtrlMsg.Result = new long[] { _connection.WrittenBytes - _connection.ClientBytesRead, maxStream / 2 }; } else if ("chunkSize".Equals(oobCtrlMsg.ServiceName)) { int newSize = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"]; if (newSize != _chunkSize) { _chunkSize = newSize; SendChunkSize(); } } }