Example #1
0
        public void AddMethodHandler(InterfaceDescription.InterfaceDescriptionMember member, MessageReceiverDelegate handler)
        {
            alljoyn_messagereceiver_methodhandler_ptr h = (bus, member2, message) =>
            {
                handler(
                    IsDisposed ? new BusObject(bus) : this,
                    new InterfaceDescription.InterfaceDescriptionMember((alljoyn_interfacedescription_member)Marshal.PtrToStructure(member2, typeof(alljoyn_interfacedescription_member))),
                    new Message(message));
            };

            pinnedMethodHandlers.Add(h);

            GCHandle    membGch = GCHandle.Alloc(member.Handle, GCHandleType.Pinned);
            MethodEntry entry;

            entry.member         = membGch.AddrOfPinnedObject();
            entry.method_handler = Marshal.GetFunctionPointerForDelegate(h);
            GCHandle gch = GCHandle.Alloc(entry, GCHandleType.Pinned);

            AllJoynException.CheckStatus(alljoyn_busobject_addmethodhandlers(Handle, gch.AddrOfPinnedObject(), (UIntPtr)1));

            gch.Free();
            membGch.Free();
        }
Example #2
0
 internal static extern QStatus alljoyn_busobject_addmethodhandler(IntPtr bus, alljoyn_interfacedescription_member member, alljoyn_messagereceiver_methodhandler_ptr handler, IntPtr context);