示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagesController"/> class.
 /// </summary>
 /// <param name="mapper">An <see cref="IMapper"/>.</param>
 /// <param name="messageComponent">An <see cref="IMessageComponent"/>.</param>
 public MessagesController(
     IMapper mapper,
     IMessageComponent messageComponent)
 {
     this.mapper           = mapper;
     this.messageComponent = messageComponent;
 }
示例#2
0
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if (typeof(IPassive).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("init"))
         {
             _start = System.Convert.ToInt32(oobCtrlMsg.ServiceParameterMap["startTS"]);
         }
     }
     else if (typeof(ISeekableProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("seek"))
         {
             int position = System.Convert.ToInt32(oobCtrlMsg.ServiceParameterMap["position"]);
             int seekPos  = Seek(position);
             // Return position we seeked to
             oobCtrlMsg.Result = seekPos;
         }
     }
     else if (typeof(IStreamTypeAwareProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("hasVideo"))
         {
             oobCtrlMsg.Result = this.HasVideo();
         }
     }
 }
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if ("ClientBroadcastStream".Equals(oobCtrlMsg.Target) && "chunkSize".Equals(oobCtrlMsg.ServiceName))
     {
         this._chunkSize = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"];
         this.NotifyChunkSize();
     }
 }
 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);
             }
         }
     }
 }
        internal SocketMessageComponentData(IMessageComponent component)
        {
            CustomId = component.CustomId;
            Type     = component.Type;

            Value = component.Type == ComponentType.TextInput
                ? (component as API.TextInputComponent).Value.Value
                : null;

            Values = component.Type == ComponentType.SelectMenu
                ? (component as API.SelectMenuComponent).Values.Value
                : null;
        }
示例#6
0
        static void Main()
        {
            IMessageComponent messageComponent = Factory.CreateMessageComponent();

            Console.WriteLine("Please enter your name");

            IGreetingComponent greetingComponent = Factory.CreateGreetingComponent();
            string             greeting          = greetingComponent.AddInitialGreeting(Console.ReadLine());

            Console.WriteLine(greeting);

            messageComponent.SendMessage(greeting);
        }
示例#7
0
        internal RestMessageComponentData(IMessageComponent component)
        {
            CustomId = component.CustomId;
            Type     = component.Type;

            if (component is API.TextInputComponent textInput)
            {
                Value = textInput.Value.Value;
            }

            if (component is API.SelectMenuComponent select)
            {
                Values = select.Values.Value;
            }
        }
示例#8
0
        static void Main()
        {
            IMessageComponent  messageComponent  = Factory.CreateMessageComponent();
            IGreetingComponent greetingComponent = Factory.CreateGreetingComponent();

            string returnedMessage = messageComponent.GetMessage();
            string usersName       = greetingComponent.RemoveInitalGreeting(returnedMessage);

            if (!greetingComponent.ValidateName(usersName))
            {
                Console.WriteLine("Please enter a valid name");
                return;
            }
            Console.WriteLine(greetingComponent.AddIconicLine(usersName));
            Console.ReadLine();
        }
示例#9
0
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if (typeof(IPassive).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("Init"))
         {
             int num = (int)oobCtrlMsg.ServiceParameterMap["startTS"];
             this._start = num;
         }
     }
     else if (typeof(ISeekableProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("Seek"))
         {
             int ts   = (int)oobCtrlMsg.ServiceParameterMap["position"];
             int num3 = this.Seek(ts);
             oobCtrlMsg.Result = num3;
         }
     }
     else if (typeof(IStreamTypeAwareProvider).Name.Equals(oobCtrlMsg.Target) && oobCtrlMsg.ServiceName.Equals("HasVideo"))
     {
         oobCtrlMsg.Result = this.HasVideo();
     }
 }
示例#10
0
 /// <summary>
 /// Out-of-band control message handler.
 /// </summary>
 /// <param name="source">Source of message.</param>
 /// <param name="pipe">Pipe that is used to transmit OOB message.</param>
 /// <param name="oobCtrlMsg">OOB control message.</param>
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
 }
 /// <summary>
 /// Out-of-band control message handler.
 /// </summary>
 /// <param name="source">OOB message source.</param>
 /// <param name="pipe">Pipe that used to send OOB message.</param>
 /// <param name="oobCtrlMsg">Out-of-band control message.</param>
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if (!"ClientBroadcastStream".Equals(oobCtrlMsg.Target))
         return;
     if ("chunkSize".Equals(oobCtrlMsg.ServiceName))
     {
         _chunkSize = (int)oobCtrlMsg.ServiceParameterMap["chunkSize"];
         NotifyChunkSize();
     }
 }
示例#12
0
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if(typeof(IPassive).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("init"))
         {
             _start = System.Convert.ToInt32(oobCtrlMsg.ServiceParameterMap["startTS"]);
         }
     }
     else if (typeof(ISeekableProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("seek"))
         {
             int position = System.Convert.ToInt32(oobCtrlMsg.ServiceParameterMap["position"]);
             int seekPos = Seek(position);
             // Return position we seeked to
             oobCtrlMsg.Result = seekPos;
         }
     }
     else if (typeof(IStreamTypeAwareProvider).Name.Equals(oobCtrlMsg.Target))
     {
         if (oobCtrlMsg.ServiceName.Equals("hasVideo"))
         {
             oobCtrlMsg.Result = this.HasVideo();
         }
     }
 }
示例#13
0
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
     if ("ConnectionConsumer".Equals(oobCtrlMsg.Target))
     {
         if (source is IProvider)
         {
             _msgOut.SendOOBControlMessage((IProvider)source, oobCtrlMsg);
         }
     }
 }
示例#14
0
        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();
                }
            }
        }
        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();
                }
            }
        }
示例#16
0
 /// <summary>
 /// Handles out-of-band control message.
 /// </summary>
 /// <param name="source">Message component source.</param>
 /// <param name="pipe">Connection pipe.</param>
 /// <param name="oobCtrlMsg">Out-of-band control message</param>
 public void OnOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg)
 {
 }
示例#17
0
 private void AddComponent(IMessageComponent component)
 {
     _components.Add(component);
     _length += component.Length;
 }