Пример #1
0
            /**
             * Add a method handler to this object. The interface for the method handler must have already
             * been added by calling AddInterface().
             *
             * @param member   Interface member implemented by handler.
             * @param handler  Method handler.
             *
             * @return
             *      - QStatus.OK if the method handler was added.
             *      - An error status otherwise
             */
            public QStatus AddMethodHandler(InterfaceDescription.Member member, MethodHandler handler)
            {
                InternalMethodHandler internalMethodHandler = (IntPtr bus, IntPtr m, IntPtr msg) =>
                {
                    MethodHandler h = handler;
                    h(new InterfaceDescription.Member(m), new Message(msg));
                };

                _methodHandlerDelegateRefHolder.Add(internalMethodHandler);

                GCHandle membGch = GCHandle.Alloc(member._member, GCHandleType.Pinned);

                MethodEntry entry;

                entry.member         = membGch.AddrOfPinnedObject();
                entry.method_handler = Marshal.GetFunctionPointerForDelegate(internalMethodHandler);

                GCHandle gch = GCHandle.Alloc(entry, GCHandleType.Pinned);
                QStatus  ret = alljoyn_busobject_addmethodhandlers(_busObject, gch.AddrOfPinnedObject(), (UIntPtr)1);

                gch.Free();
                membGch.Free();

                return(ret);
            }
Пример #2
0
 /**
  * Send a signal.
  *
  * @param destination      The unique or well-known bus name or the signal recipient (NULL for broadcast signals)
  * @param sessionId        A unique SessionId for this AllJoyn session instance
  * @param signal           Interface member of signal being emitted.
  * @param args             The arguments for the signal (can be NULL)
  * @param timeToLife       If non-zero this specifies in milliseconds the useful lifetime for this
  *                         signal. If delivery of the signal is delayed beyond the timeToLive due to
  *                         network congestion or other factors the signal may be discarded. There is
  *                         no guarantee that expired signals will not still be delivered.
  * @param flags            Logical OR of the message flags for this signals. The following flags apply to signals:
  *                         - If ALLJOYN_FLAG_SESSIONLESS is set the signal will be sent out to any listener without
  *                           requireing a connected session
  *                         - If ALLJOYN_FLAG_GLOBAL_BROADCAST is set broadcast signal (null destination) will be
  *                           forwarded across bus-to-bus connections.
  *                         - If ALLJOYN_FLAG_COMPRESSED is set the header is compressed for destinations that can
  *                           handle header compression.
  *                         - If ALLJOYN_FLAG_ENCRYPTED is set the message is authenticated and the payload if any
  *                           is encrypted.
  * @param msg              The sent signal message is returned to the caller.
  * @return
  *      - QStatus.OK if successful
  *      - An error status otherwise
  */
 protected QStatus Signal(string destination, uint sessionId, InterfaceDescription.Member signal,
                          MsgArg args, ushort timeToLife, byte flags, Message msg)
 {
     return(alljoyn_busobject_signal(_busObject, destination, sessionId, signal._member, args.UnmanagedPtr, (UIntPtr)args.Length, timeToLife, flags, msg.UnmanagedPtr));
 }
Пример #3
0
 /**
  * Send a signal.
  *
  * @param destination      The unique or well-known bus name or the signal recipient (NULL for broadcast signals)
  * @param sessionId        A unique SessionId for this AllJoyn session instance
  * @param signal           Interface member of signal being emitted.
  * @param args             The arguments for the signal (can be NULL)
  * @return
  *      - QStatus.OK if successful
  *      - An error status otherwise
  */
 protected QStatus Signal(string destination, uint sessionId, InterfaceDescription.Member signal, MsgArg args)
 {
     return(alljoyn_busobject_signal(_busObject, destination, sessionId, signal._member, args.UnmanagedPtr, (UIntPtr)args.Length, 0, 0, IntPtr.Zero));
 }