コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the ChatSessionObject class. 
        /// </summary>
        /// <param name="bus">The BusAttachment to be associated with.</param>
        /// <param name="path">The path for the BusObject.</param>
        /// <param name="host">The instance of the MainPage which handles the UI for this
        /// application.</param>
        public ChatSessionObject(BusAttachment bus, string path, MainPage host)
        {
            try
            {
                this.hostPage = host;
                this.busObject = new BusObject(bus, path, false);

                /* Add the interface to this object */
                InterfaceDescription[] ifaceArr = new InterfaceDescription[1];
                bus.CreateInterface(ChatServiceInterfaceName, ifaceArr, false);
                ifaceArr[0].AddSignal("Chat", "s", "str", 0, string.Empty);
                ifaceArr[0].Activate();

                InterfaceDescription chatIfc = bus.GetInterface(ChatServiceInterfaceName);

                this.busObject.AddInterface(chatIfc);

                this.chatSignalReceiver = new MessageReceiver(bus);
                this.chatSignalReceiver.SignalHandler += new MessageReceiverSignalHandler(this.ChatSignalHandler);
                this.chatSignalMember = chatIfc.GetMember("Chat");
                bus.RegisterSignalHandler(this.chatSignalReceiver, this.chatSignalMember, path);
            }
            catch (System.Exception ex)
            {
                QStatus errCode = AllJoyn.AllJoynException.GetErrorCode(ex.HResult);
                string errMsg = AllJoyn.AllJoynException.GetErrorMessage(ex.HResult);
                this.hostPage.DisplayStatus("Create ChatSessionObject Error : " + errMsg);
            }
        }
コード例 #2
0
ファイル: Listeners.cs プロジェクト: peterdocter/Coco2dxDemo
        /// <summary>
        /// Initializes a new instance of the Listeners class.
        /// </summary>
        /// <param name="bus">The bus to listen on.</param>
        /// <param name="host">The main page which handles the user interface.</param>
        public Listeners(BusAttachment bus, MainPage host)
        {
            this.hostPage = host;
            this.busListeners = new BusListener(bus);
            this.busListeners.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
            this.busListeners.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
            this.busListeners.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
            this.busListeners.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
            this.busListeners.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
            this.busListeners.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
            this.busListeners.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);

            this.sessionPortListener = new SessionPortListener(bus);
            this.sessionPortListener.AcceptSessionJoiner += new SessionPortListenerAcceptSessionJoinerHandler(this.SessionPortListenerAcceptSessionJoiner);
            this.sessionPortListener.SessionJoined += new SessionPortListenerSessionJoinedHandler(this.SessionPortListenerSessionJoined);

            this.sessionListener = new SessionListener(bus);
            this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
            this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
            this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);
        }