public void onDefault(UdbusMessagePair messageData)
 {
     foreach (IUdbusMessageVisitor visitor in this.visitors)
     {
         visitor.onDefault(messageData);
     } // Ends loop over visitors
 }
Esempio n. 2
0
 public void HandleSignalMessage(UdbusMessagePair messageData)
 {
     foreach (IHandleDbusSignal handler in this.handlers)
     {
         handler.HandleSignalMessage(messageData);
     }
 }
 public void onMethodReturn(UdbusMessagePair messageData)
 {
     foreach (IUdbusMessageVisitor visitor in this.visitors)
     {
         visitor.onMethodReturn(messageData);
     } // Ends loop over visitors
 }
 public void onError(UdbusMessagePair messageData)
 {
     foreach (IUdbusMessageVisitor visitor in this.visitors)
     {
         visitor.onError(messageData);
     }
 }
 protected override void HandleMessage(UdbusMessagePair messageData)
 {
     if (messageData.Data.reply_serial == this.serialholder.Serial)
     {
         this.bStop = true;
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Receive a dbus message.
        /// </summary>
        /// <param name="id">Id of message to receive.</param>
        /// <returns>Received message.</returns>
        public UdbusMessagePair ReceiveMessage(uint id, out int result)
        {
            UdbusMessagePair resultData = this.receiverPool.ReceiveMessageData(this.serviceConnectionParams.Connector, id, out result);

            this.receiverPool.TracePool();
            return(resultData);
        }
        public static int Visit(int result, UdbusMessagePair messageData, IUdbusMessageVisitor visitor)
        {
            UdbusMessagePair releaseMessageData;
            int visitResult = Visit(result, messageData, visitor, out releaseMessageData);

            //releaseMessageData.Dispose();
            return(visitResult);
        }
        internal static int Visit(int result, Udbus.Serialization.NMessageHandle.UdbusMessageHandle msg, IUdbusMessageVisitor visitor, out UdbusMessagePair releaseMessageData)
        {
            if (result == 0)
            {
                UdbusMessagePair messageData = new UdbusMessagePair(msg);
                result = Visit(result, messageData, visitor, out releaseMessageData);
            }
            else
            {
                HandleMessageError(result, visitor, out releaseMessageData);
            }

            return(result);
        }
        /// <summary>
        /// Call into a visitor, and pass back message data if visitor stops.
        /// </summary>
        /// <remarks>
        /// Note that it is up to calling code to dispose of the message handle,
        /// and that if the visitor Stop flag is set the message handle is moved into the out parameter
        /// evading disposal.
        /// </remarks>
        /// <param name="result">Receive result.</param>
        /// <param name="messageData">Received message data.</param>
        /// <param name="visitor">Visitor to handle message handle.</param>
        /// <param name="releaseMessageData">Message data if visitor sets Stop flag.</param>
        /// <returns>Receive result.</returns>
        public static int Visit(int result, UdbusMessagePair messageData, IUdbusMessageVisitor visitor, out UdbusMessagePair releaseMessageData)
        {
            releaseMessageData = default(UdbusMessagePair);

            if (result == 0) // If got message ok
            {
                switch ((Udbus.Types.dbus_msg_type)messageData.Data.typefield.type)
                {
                case Udbus.Types.dbus_msg_type.DBUS_TYPE_METHOD_CALL:
                    visitor.onMethod(messageData);
                    break;

                case Udbus.Types.dbus_msg_type.DBUS_TYPE_SIGNAL:
                    visitor.onSignal(messageData);
                    break;

                case Udbus.Types.dbus_msg_type.DBUS_TYPE_METHOD_RETURN:
                    visitor.onMethodReturn(messageData);
                    break;

                case Udbus.Types.dbus_msg_type.DBUS_TYPE_ERROR:
                    visitor.onError(messageData);
                    break;

                default:
                    visitor.onDefault(messageData);
                    break;
                } // Ends switch received message type

                if (visitor.Stop) // If stopping
                {
                    // No disposing thanks very much.
                    //UdbusMessagePair releaseMessageData = messageData.Release();
                    releaseMessageData = messageData.Release();
                    //msg.Release();
                } // Ends if stopping
            }     // Ends if got message ok
            else  // Else failed to get message
            {
                HandleMessageError(result, visitor);
            } // Ends else failed to get message

            return(result);
        }
Esempio n. 10
0
        public static UdbusMessagePair LoopUdbusFind(Udbus.Serialization.UdbusConnector connector, IUdbusMessageVisitor visitor, System.IO.TextWriter output, System.Threading.WaitHandle stop)
        {
            output.WriteLine("Looping...");
            int r = 0;
            UdbusMessagePair result = default(UdbusMessagePair);

            while (r == 0 && visitor.Stop == false && stop.WaitOne(0) == false)
            {
                using (var msg = connector.ReceiveHandle(out r))
                {
                    Visit(r, msg, visitor, out result);
                } // Ends using received message
            }     // Ends loop while getting results and not told to stop

            visitor.Reset();

            output.WriteLine("Finished looping...");

            return(result);
        }
Esempio n. 11
0
        public override void onSignal(UdbusMessagePair messageData)
        {
            const string StorageSpaceLow = "storage_space_low";

            if (messageData.Data.method.StartsWith(StorageSpaceLow))
            {
                Udbus.Serialization.UdbusMessageReader reader = new Udbus.Serialization.UdbusMessageReader(messageData.Handle);
                Int32 percentage = 0;
                int   result     = reader.ReadInt32(out percentage);
                if (result != 0)
                {
                    this.dumpError(messageData, "Reading percentage from storage space low signal");
                }
                else
                {
                    this.dumpStuff(messageData, string.Format("Signal. Left {0}%", percentage));
                }
            }
            else
            {
                base.onSignal(messageData);
            }
        }
Esempio n. 12
0
        public UdbusMessagePair Clone()
        {
            UdbusMessagePair clone = new UdbusMessagePair(this);

            return(clone);
        }
Esempio n. 13
0
 public virtual void onDefault(UdbusMessagePair messageData)
 {
     this.dumpStuff(messageData, "Dunno");
 }
Esempio n. 14
0
 public virtual void onMethodReturn(UdbusMessagePair messageData)
 {
     this.dumpStuff(messageData, "Method Return");
 }
Esempio n. 15
0
 virtual protected void dumpError(UdbusMessagePair messageData, string description)
 {
     this.dDumpError(messageData, "Error: " + description);
 }
Esempio n. 16
0
 public void onError(UdbusMessagePair messageData)
 {
 }
Esempio n. 17
0
 virtual protected void dumpStuff(UdbusMessagePair messageData, string description)
 {
     this.dDump(messageData, description);
 }
Esempio n. 18
0
 public void onDefault(UdbusMessagePair messageData)
 {
 }
Esempio n. 19
0
 public virtual void onSignal(UdbusMessagePair messageData)
 {
     this.dumpStuff(messageData, "Signal");
 }
Esempio n. 20
0
 abstract protected void HandleMessage(UdbusMessagePair messageData);
Esempio n. 21
0
 public void onError(UdbusMessagePair messageData)
 {
     this.dumpStuff(messageData, "Error message");
 }
Esempio n. 22
0
 public virtual void onSignal(UdbusMessagePair messageData)
 {
     this.HandleMessage(messageData);
 }
Esempio n. 23
0
        public void onResultError(int error)
        {
            UdbusMessagePair errordata = new UdbusMessagePair();

            this.dDumpError(errordata, string.Format("Error result: {0}", error));
        }
Esempio n. 24
0
 public virtual void onMethodReturn(UdbusMessagePair messageData)
 {
     this.HandleMessage(messageData);
 }
Esempio n. 25
0
 protected override void HandleMessage(UdbusMessagePair messageData)
 {
     this.stop = true;
 }
Esempio n. 26
0
 public void onError(UdbusMessagePair messageData)
 {
     this.HandleMessage(messageData);
 }
Esempio n. 27
0
 public void HandleSignalMessage(UdbusMessagePair messageData)
 {
 }
Esempio n. 28
0
 public virtual void onDefault(UdbusMessagePair messageData)
 {
     this.HandleMessage(messageData);
 }
Esempio n. 29
0
 public void HandleSignalMessage(UdbusMessagePair messageData)
 {
     this.writemessage(messageData.Data.ToString());
 }
Esempio n. 30
0
 private UdbusMessagePair(UdbusMessagePair source)
     : this(source.Handle, source.data)
 {
 }