Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyBusListener" /> class.
        /// </summary>
        /// <param name="busAtt">object responsible for connecting to and optionally managing a message
        /// bus.</param>
        /// <param name="ops">Session operations object for this application</param>
        public MyBusListener(BusAttachment busAtt, SessionOperations ops)
        {
            this.sessionOps = ops;

            // Create Bus Listener and register signal handlers
            this.busListener = new BusListener(busAtt);
            this.busListener.BusDisconnected      += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
            this.busListener.BusStopping          += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
            this.busListener.FoundAdvertisedName  += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
            this.busListener.ListenerRegistered   += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
            this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
            this.busListener.LostAdvertisedName   += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
            this.busListener.NameOwnerChanged     += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);

            // Create Session Listener and register signal handlers
            this.sessionListener                       = new SessionListener(busAtt);
            this.sessionListener.SessionLost          += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
            this.sessionListener.SessionMemberAdded   += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
            this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);

            // Create Session Port Listener and register signal handlers
            this.sessionPortListener = new SessionPortListener(busAtt);
            this.sessionPortListener.AcceptSessionJoiner += new SessionPortListenerAcceptSessionJoinerHandler(this.SessionPortListenerAcceptSessionJoiner);
            this.sessionPortListener.SessionJoined       += new SessionPortListenerSessionJoinedHandler(this.SessionPortListenerSessionJoined);

            busAtt.RegisterBusListener(this.busListener);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyBusListener" /> class.
        /// </summary>
        /// <param name="busAtt">object responsible for connecting to and optionally managing a message
        /// bus.</param>
        /// <param name="ops">Session operations object for this application</param>
        public MyBusListener(BusAttachment busAtt, SessionOperations ops)
        {
            this.sessionOps = ops;

            // Create Bus Listener and register signal handlers 
            this.busListener = new BusListener(busAtt);
            this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected);
            this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping);
            this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName);
            this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered);
            this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered);
            this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName);
            this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged);

            // Create Session Listener and register signal handlers 
            this.sessionListener = new SessionListener(busAtt);
            this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost);
            this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded);
            this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved);

            // Create Session Port Listener and register signal handlers 
            this.sessionPortListener = new SessionPortListener(busAtt);
            this.sessionPortListener.AcceptSessionJoiner += new SessionPortListenerAcceptSessionJoinerHandler(this.SessionPortListenerAcceptSessionJoiner);
            this.sessionPortListener.SessionJoined += new SessionPortListenerSessionJoinedHandler(this.SessionPortListenerSessionJoined);

            busAtt.RegisterBusListener(this.busListener);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage"/> class
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            Application.Current.Suspending += new Windows.UI.Xaml.SuspendingEventHandler(App_Suspending);
            Application.Current.Resuming += new EventHandler<Object>(App_Resuming);

            this.sessionOps = new SessionOperations(this);

            // Set OS Logging to false so debug prints are written to log file in My Docs
            // To have ability to write to log file must change manifest file so capabilities
            // includes My Docs access and add 'File Type Association' in Declarations for
            // .log files
            AllJoyn.Debug.UseOSLogging(false);
            Application.Current.Suspending += new Windows.UI.Xaml.SuspendingEventHandler(App_Suspending);
            Application.Current.Resuming += new EventHandler<Object>(App_Resuming);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyBusObject"/> class
        /// </summary>
        /// <param name="busAtt">Message bus for the sessions app</param>
        /// <param name="ops">Session Operations object for this application</param>
        public MyBusObject(BusAttachment busAtt, SessionOperations ops)
        {
            this.busObject = new BusObject(busAtt, BusObjectPath, false);
            this.sessionOps = ops;
            this.ChatEcho = true;

            // Implement the 'Chat' interface
            InterfaceDescription[] intfDescription = new InterfaceDescription[1];
            busAtt.CreateInterface(SessionInterfaceName, intfDescription, false);
            intfDescription[0].AddSignal("Chat", "s", "str", (byte)0, string.Empty);
            intfDescription[0].Activate();
            this.chatSignal = intfDescription[0].GetSignal("Chat");
            this.busObject.AddInterface(intfDescription[0]);

            // Register chat signal handler 
            MessageReceiver signalReceiver = new MessageReceiver(busAtt);
            signalReceiver.SignalHandler += new MessageReceiverSignalHandler(this.ChatSignalHandler);
            busAtt.RegisterSignalHandler(signalReceiver, this.chatSignal, string.Empty);

            busAtt.RegisterBusObject(this.busObject);
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyBusObject"/> class
        /// </summary>
        /// <param name="busAtt">Message bus for the sessions app</param>
        /// <param name="ops">Session Operations object for this application</param>
        public MyBusObject(BusAttachment busAtt, SessionOperations ops)
        {
            this.busObject  = new BusObject(busAtt, BusObjectPath, false);
            this.sessionOps = ops;
            this.ChatEcho   = true;

            // Implement the 'Chat' interface
            InterfaceDescription[] intfDescription = new InterfaceDescription[1];
            busAtt.CreateInterface(SessionInterfaceName, intfDescription, false);
            intfDescription[0].AddSignal("Chat", "s", "str", (byte)0, string.Empty);
            intfDescription[0].Activate();
            this.chatSignal = intfDescription[0].GetSignal("Chat");
            this.busObject.AddInterface(intfDescription[0]);

            // Register chat signal handler
            MessageReceiver signalReceiver = new MessageReceiver(busAtt);

            signalReceiver.SignalHandler += new MessageReceiverSignalHandler(this.ChatSignalHandler);
            busAtt.RegisterSignalHandler(signalReceiver, this.chatSignal, string.Empty);

            busAtt.RegisterBusObject(this.busObject);
        }