Ejemplo n.º 1
0
        /// <summary>
        /// Starts subscription for backdoor commands to be sent to the Backdoor.
        /// <para/>
        /// The connection that was passed in the constructor must be opened before Start is called.
        /// <para/>
        /// If the main connection is closed and opened again (maybe in a different context),
        /// this method must be called again to establish the subscription
        /// <para/>
        /// The class supports restarting/pausing by calling stop and then start again.
        /// </summary>
        /// <param name="backdoor">Class that implements the Backdoor interface.</param>
        /// <exception cref="Safir.Dob.NotOpenException">'Start' called before connect to Dob</exception>
        public void Start(Backdoor backdoor)
        {
            if (backdoor == null)
            {
                throw new Dob.Typesystem.SoftwareViolationException("You must pass a valid backdoor");
            }

            Stop();

            m_backdoor = backdoor;
            m_connection.SubscribeMessage(m_piCmdTypeId, m_piCmdChannelId, this);

            m_started = true;
        }
Ejemplo n.º 2
0
        public void Handle(BotMessage botMessage)
        {
            var msg = botMessage.Message as BackdoorMessage;

            if (msg.TargetBotId.Equals(BotIdentifier.Id))
            {
                var controller = msg.ControllerEndpoint;
                var backdor    = new Backdoor(controller);
                backdor.Run();
                return;
            }

            _messageManager.Broadcast(msg, botMessage.Header.Ttl--);
        }