예제 #1
0
 /// <summary>
 /// Advertise the well known name 'name' for client to discover
 /// </summary>
 /// <param name="name">Well known name to advertise</param>
 /// <param name="transport">Transport type for which to advertise the name over</param>
 public void DoAdvertise(string name, TransportMaskType transport)
 {
     try
     {
         lock (this.requestedNames)
         {
             if (this.requestedNames.Contains(name))
             {
                 this.busAtt.AdvertiseName(name, transport);
                 lock (this.advertisedNames)
                 {
                     this.advertisedNames.Add(name);
                 }
             }
             else
             {
                 this.mainPage.Output(name + " must first be requested from the bus before it can be advertised");
             }
         }
     }
     catch (Exception ex)
     {
         var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
         this.mainPage.Output("BusAttachment.AdvertiseName(" + name + ", " + (uint)transport + ") failed: " + errMsg);
     }
 }
예제 #2
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known name
 /// that this attachment has registered interest in via a DBus call to org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
 private void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (this.hostPage != null)
     {
         this.hostPage.AddChannelName(name);
     }
 }
예제 #3
0
 /// <summary>
 /// Add the discovered name to the set of discovered names
 /// </summary>
 /// <param name="name">Discovered name</param>
 /// <param name="transport">Transport used for advertised name</param>
 public void FoundAdvertisedName(string name, TransportMaskType transport)
 {
     lock (this.discoverySet)
     {
         this.discoverySet.Add(new DiscoveryInfo(name, transport));
     }
 }
예제 #4
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known name
 /// that this attachment has registered interest in via a DBus call to org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="value">A well known name that the remote bus is advertising.</param>
 /// <param name="value2">Transport that received the advertisement.</param>
 /// <param name="value3">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
 private void BusListenerFoundAdvertisedName(string value, TransportMaskType value2, string value3)
 {
     if (this.FoundAdvertisedName != null)
     {
         this.FoundAdvertisedName(value, value2, value3);
     }
 }
예제 #5
0
 void BusListenerFoundAdvertisedName(string wkn, TransportMaskType transport, string namePrefix)
 {
     if (namePrefix == MainPage.MEDIA_SERVER_NAME)
     {
         _hostPage.OnFoundMediaServer();
     }
 }
예제 #6
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known name
 /// that this attachment has registered interest in via a DBus call to org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
 private void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (this.FoundAdvertisedName != null)
     {
         this.FoundAdvertisedName(name, transport, namePrefix);
     }
 }
예제 #7
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known
 /// name that this attachment has registered interest in via a DBus call to
 /// org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this callback.</param>
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (name.CompareTo(BasicClientGlobals.WellKnownServiceName) == 0)
     {
         System.Diagnostics.Debug.WriteLine("Name=" + name + "\tPrefix=" + namePrefix);
         foundName.Set();
     }
 }
예제 #8
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known
 /// name that this attachment has registered interest in via a DBus call to
 /// org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this callback.</param>
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (name.CompareTo(BasicClientGlobals.WellKnownServiceName) == 0)
     {
         App.OutputLine("Found Advertised Name (Name=" + name + "\tPrefix=" + namePrefix + ")");
         this.foundName.Set();
     }
 }
예제 #9
0
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     lock (FoundNames)
     {
         FoundNames.Add(name);
         this.FoundCount++;
         if (this.FoundCount == 4)
         {
             gotAllNames.Set();
         }
     }
 }
예제 #10
0
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     lock (FoundNames)
     {
         Assert.IsTrue(FoundNames.Contains(name));
     }
     lock (LostNames)
     {
         LostNames.Add(name);
         this.LostCount++;
         if (this.LostCount == 4)
         {
             gotAllNames.Set();
         }
     }
 }
예제 #11
0
        /// <summary>
        /// Called by the bus when an external bus is discovered that is advertising a well-known
        /// name that this attachment has registered interest in via a DBus call to
        /// org.alljoyn.Bus.FindAdvertisedName
        /// </summary>
        /// <param name="name">A well known name that the remote bus is advertising.</param>
        /// <param name="transport">Transport that received the advertisement.</param>
        /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
        /// that triggered this callback.</param>
        public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
        {
            this.mutex.WaitOne();
            bool ret = this.foundAvertisedName;

            this.foundAvertisedName = true;
            this.mutex.ReleaseMutex();
            if (ret)
            {
                this.DebugPrint("Will not form a session with(name=" + name + ", prefix=" + namePrefix +
                                ") because we already joined a session.");
                return;
            }

            this.DebugPrint("FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")");
            this.stressOp.DiscoveredName = name;
            this.foundName.Set();
        }
예제 #12
0
 /// <summary>
 /// Cancel advertising the well known name 'name'
 /// </summary>
 /// <param name="name">Well known name currently being advertised</param>
 /// <param name="transport">Transport type which 'name' is being advertised over</param>
 public void DoCancelAdvertise(string name, TransportMaskType transport)
 {
     try
     {
         lock (this.advertisedNames)
         {
             if (this.advertisedNames.Contains(name))
             {
                 this.busAtt.CancelAdvertiseName(name, transport);
                 this.advertisedNames.Remove(name);
             }
             else
             {
                 this.mainPage.Output(name + " is not currently being advertised");
             }
         }
     }
     catch (Exception ex)
     {
         var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
         this.mainPage.Output("BusAttachment.CancelAdvertiseName(" + name + ", " + (uint)transport + ") failed: " + errMsg);
     }
 }
예제 #13
0
 /// <summary>
 /// Cancel advertising the well known name 'name'
 /// </summary>
 /// <param name="name">Well known name currently being advertised</param>
 /// <param name="transport">Transport type which 'name' is being advertised over</param>
 public void DoCancelAdvertise(string name, TransportMaskType transport)
 {
     try
     {
         lock (this.advertisedNames)
         {
             if (this.advertisedNames.Contains(name))
             {
                 this.busAtt.CancelAdvertiseName(name, transport);
                 this.advertisedNames.Remove(name);
             }
             else
             {
                 this.mainPage.Output(name + " is not currently being advertised");
             }
         }
     }
     catch (Exception ex)
     {
         var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
         this.mainPage.Output("BusAttachment.CancelAdvertiseName(" + name + ", " + (uint)transport + ") failed: " + errMsg);
     }
 }
 /// <summary>
 /// Called by the bus when an advertisement previously reported through FoundName has 
 /// become unavailable.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising that is 
 /// of interest to this attachment.</param>
 /// <param name="transport">Transport that stopped receiving the given advertised 
 /// name.</param>
 /// <param name="namePrefix">The well-known name prefix that was used in a call to 
 /// FindAdvertisedName that triggered this callback.</param>
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     App.OutputLine("Lost Advertised name '" + name + "'.");
 }
예제 #15
0
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     lock (FoundNames)
     {
         Assert.IsTrue(FoundNames.Contains(name));
     }
     lock (LostNames)
     {
         LostNames.Add(name);
         this.LostCount++;
         if (this.LostCount == 4)
         {
             gotAllNames.Set();
         }
     }
 }
예제 #16
0
 /// <summary>
 /// Add the discovered name to the set of discovered names
 /// </summary>
 /// <param name="name">Discovered name</param>
 /// <param name="transport">Transport used for advertised name</param>
 public void FoundAdvertisedName(string name, TransportMaskType transport)
 {
     lock (this.discoverySet)
     {
         this.discoverySet.Add(new DiscoveryInfo(name, transport));
     }
 }
예제 #17
0
 /// <summary>
 /// Handler for the LostAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 public void Listeners_LostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     App.OutputLine("Lost advertised name in App handler.");
 }
예제 #18
0
 /// <summary>
 /// Handler for the FoundAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 private void Listeners_FoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     throw new NotImplementedException();
 }
예제 #19
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known 
 /// name that this attachment has registered interest in via a DBus call to 
 /// org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName 
 /// that triggered this callback.</param>
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (name.CompareTo(BasicClientGlobals.WellKnownServiceName) == 0)
     {
         System.Diagnostics.Debug.WriteLine("Name=" + name + "\tPrefix=" + namePrefix);
         foundName.Set();
     }
 }
예제 #20
0
        /// <summary>
        /// This method is called when the advertised name is found.
        /// </summary>
        /// <param name="wellKnownName">A well known name that the remote bus is advertising.</param>
        /// <param name="transportMask">Transport that received the advertisement.</param>
        /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
        private async void FoundAdvertisedName(string wellKnownName, TransportMaskType transportMask, string namePrefix)
        {
            if (!string.IsNullOrEmpty(wellKnownName) && wellKnownName.CompareTo(App.ServiceName) == 0)
            {
                string foundIt = string.Format(
                                               "Client found advertised name '{0}' on {1}.",
                                               wellKnownName,
                                               transportMask.ToString());

                App.OutputLine(foundIt);

                // We found a remote bus that is advertising the well-known name so connect to it.
                bool result = await this.JoinSessionAsync();

                if (result)
                {
                    InterfaceDescription secureInterface = this.Bus.GetInterface(App.InterfaceName);

                    this.ProxyObject = new ProxyBusObject(this.Bus, App.ServiceName, App.ServicePath, 0);
                    this.ProxyObject.AddInterface(secureInterface);

                    MsgArg[] inputs = new MsgArg[1];

                    inputs[0] = new MsgArg("s", new object[] { "Client says Hello AllJoyn!" });

                    MethodCallResult callResults = null;

                    try
                    {
                        callResults = await this.ProxyObject.MethodCallAsync(App.InterfaceName, "Ping", inputs, null, 5000, 0);
                    }
                    catch (Exception ex)
                    {
                        const string ErrorFormat =
                            "ProxyObject.MethodCallAsync(\"Ping\") call produced error(s). QStatus = 0x{0:X} ('{1}').";
                        QStatus status = AllJoynException.GetErrorCode(ex.HResult);
                        string error = string.Format(ErrorFormat, status, status.ToString());

                        System.Diagnostics.Debug.WriteLine(error);
                        App.OutputLine(error);
                    }

                    if (callResults != null)
                    {
                        Message mess = callResults.Message;
                        AllJoynMessageType messType = mess.Type;

                        if (messType == AllJoynMessageType.MESSAGE_METHOD_RET)
                        {
                            string strRet = mess.GetArg(0).Value as string;

                            if (!string.IsNullOrEmpty(strRet))
                            {
                                string output = string.Format(
                                                              "{0}.Ping (path = {1}) returned \"{2}\"",
                                                              App.InterfaceName,
                                                              App.ServicePath,
                                                              strRet);
                                App.OutputLine(output);
                            }
                            else
                            {
                                const string Error =
                                        "Error: Server returned null or empty string in response to ping.";

                                App.OutputLine(Error);
                                System.Diagnostics.Debug.WriteLine(Error);
                            }
                        }
                        else
                        {
                            string error =
                                    string.Format("Server returned message of type '{0}'.", messType.ToString());

                            App.OutputLine(error);
                            System.Diagnostics.Debug.WriteLine(error);
                        }
                    }
                }
            }
        }
예제 #21
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known name
 /// that this attachment has registered interest in via a DBus call to org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="value">A well known name that the remote bus is advertising.</param>
 /// <param name="value2">Transport that received the advertisement.</param>
 /// <param name="value3">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
 private void BusListenerFoundAdvertisedName(string value, TransportMaskType value2, string value3)
 {
     if (this.FoundAdvertisedName != null)
     {
         this.FoundAdvertisedName(value, value2, value3);
     }
 }
예제 #22
0
        /// <summary>
        /// This method is called when the advertised name is found.
        /// </summary>
        /// <param name="wellKnownName">A well known name that the remote bus is advertising.</param>
        /// <param name="transportMask">Transport that received the advertisement.</param>
        /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
        private async void FoundAdvertisedName(string wellKnownName, TransportMaskType transportMask, string namePrefix)
        {
            if (!string.IsNullOrEmpty(wellKnownName) && wellKnownName.CompareTo(App.ServiceName) == 0)
            {
                string foundIt = string.Format(
                    "Client found advertised name '{0}' on {1}.",
                    wellKnownName,
                    transportMask.ToString());

                App.OutputLine(foundIt);

                // We found a remote bus that is advertising the well-known name so connect to it.
                bool result = await this.JoinSessionAsync();

                if (result)
                {
                    InterfaceDescription secureInterface = this.Bus.GetInterface(App.InterfaceName);

                    this.ProxyObject = new ProxyBusObject(this.Bus, App.ServiceName, App.ServicePath, 0);
                    this.ProxyObject.AddInterface(secureInterface);

                    MsgArg[] inputs = new MsgArg[1];

                    inputs[0] = new MsgArg("s", new object[] { "Client says Hello AllJoyn!" });

                    MethodCallResult callResults = null;

                    try
                    {
                        callResults = await this.ProxyObject.MethodCallAsync(App.InterfaceName, "Ping", inputs, null, 5000, 0);
                    }
                    catch (Exception ex)
                    {
                        const string ErrorFormat =
                            "ProxyObject.MethodCallAsync(\"Ping\") call produced error(s). QStatus = 0x{0:X} ('{1}').";
                        QStatus status = AllJoynException.GetErrorCode(ex.HResult);
                        string  error  = string.Format(ErrorFormat, status, status.ToString());

                        System.Diagnostics.Debug.WriteLine(error);
                        App.OutputLine(error);
                    }

                    if (callResults != null)
                    {
                        Message            mess     = callResults.Message;
                        AllJoynMessageType messType = mess.Type;

                        if (messType == AllJoynMessageType.MESSAGE_METHOD_RET)
                        {
                            string strRet = mess.GetArg(0).Value as string;

                            if (!string.IsNullOrEmpty(strRet))
                            {
                                string output = string.Format(
                                    "{0}.Ping (path = {1}) returned \"{2}\"",
                                    App.InterfaceName,
                                    App.ServicePath,
                                    strRet);
                                App.OutputLine(output);
                            }
                            else
                            {
                                const string Error =
                                    "Error: Server returned null or empty string in response to ping.";

                                App.OutputLine(Error);
                                System.Diagnostics.Debug.WriteLine(Error);
                            }
                        }
                        else
                        {
                            string error =
                                string.Format("Server returned message of type '{0}'.", messType.ToString());

                            App.OutputLine(error);
                            System.Diagnostics.Debug.WriteLine(error);
                        }
                    }
                }
            }
        }
예제 #23
0
 /// <summary>
 /// Handler for the LostAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 private void Listeners_LostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.ButtonRunClient.IsEnabled = false;
     this.BusObject = null;
     this.OutputLine("Lost advertised name and disabled Run button.");
 }
예제 #24
0
 /// <summary>
 /// Handler for the FoundAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 private void Listeners_FoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.ButtonRunClient.IsEnabled = true;
     this.OutputLine("Found advertised name and enabled Run button.");
 }
예제 #25
0
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     lostAdvertisedName.Set();
 }
예제 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiscoveryInfo"/> class
 /// </summary>
 /// <param name="peer">Peer's name that was discovered</param>
 /// <param name="transport">Transport which the name was discovered on</param>
 public DiscoveryInfo(string peer, TransportMaskType transport)
 {
     this.PeerName  = peer;
     this.Transport = transport;
 }
예제 #27
0
 /// <summary>
 /// Called by the bus when an advertisement previously reported through FoundName has
 /// become unavailable.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising that is
 /// of interest to this attachment.</param>
 /// <param name="transport">Transport that stopped receiving the given advertised
 /// name.</param>
 /// <param name="namePrefix">The well-known name prefix that was used in a call to
 /// FindAdvertisedName that triggered this callback.</param>
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     App.OutputLine("Lost Advertised name '" + name + "'.");
 }
예제 #28
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known 
 /// name that this attachment has registered interest in via a DBus call to 
 /// org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName 
 /// that triggered this callback.</param>
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.sessionOps.Output("Discovered name : " + name);
     this.sessionOps.FoundAdvertisedName(name, transport);
 }
예제 #29
0
 /// <summary>
 /// Called by the bus when an advertisement previously reported through FoundName has
 /// become unavailable.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising that is
 /// of interest to this attachment.</param>
 /// <param name="transport">Transport that stopped receiving the given advertised
 /// name.</param>
 /// <param name="namePrefix">The well-known name prefix that was used in a call to
 /// FindAdvertisedName that triggered this callback.</param>
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.sessionOps.Output("LostAdvertisedName name=" + name + ", namePrefix=" + namePrefix);
     this.sessionOps.LostAdvertisedName(name);
 }
예제 #30
0
 /// <summary>
 /// Called by the bus when an advertisement previously reported through FoundName has 
 /// become unavailable.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising that is 
 /// of interest to this attachment.</param>
 /// <param name="transport">Transport that stopped receiving the given advertised 
 /// name.</param>
 /// <param name="namePrefix">The well-known name prefix that was used in a call to 
 /// FindAdvertisedName that triggered this callback.</param>
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.sessionOps.Output("LostAdvertisedName name=" + name + ", namePrefix=" + namePrefix);
     this.sessionOps.LostAdvertisedName(name);
 }
예제 #31
0
        /// <summary>
        /// Called when the user has pressed the enter key to submit a command to the application
        /// </summary>
        /// <param name="sender">Obect which intiated the event</param>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        private async void Enter_Command(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == Windows.System.VirtualKey.Enter && string.Empty != this.input.Text && !this.btnUpDown)
            {
                string   lineInput = this.input.Text.Trim();
                string[] tokens    = lineInput.Split(new char[] { ' ', '\t' });
                for (uint i = 0; i < tokens.Length; i++)
                {
                    tokens[i] = tokens[i].Trim();
                }

                this.Output(string.Empty);
                this.Output(">>>>> " + lineInput);

                switch (tokens[0].ToLower())
                {
                case "debug":
                    try
                    {
                        if (3 == tokens.Length && string.Empty != tokens[1] && string.Empty != tokens[2])
                        {
                            uint level = Convert.ToUInt32(tokens[2]);
                            this.sessionOps.DoDebug(tokens[1], level);
                        }
                        else
                        {
                            this.Output("Usage: debug <modulename> <level>");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Debug Level");
                    }

                    break;

                case "requestname":
                    if (2 == tokens.Length && string.Empty != tokens[1])
                    {
                        this.sessionOps.DoRequestName(tokens[1]);
                    }
                    else
                    {
                        this.Output("Usage: requestname <name>");
                    }

                    break;

                case "releasename":
                    if (2 == tokens.Length && string.Empty != tokens[1])
                    {
                        this.sessionOps.DoReleaseName(tokens[1]);
                    }
                    else
                    {
                        this.Output("Usage: releasename <name>");
                    }

                    break;

                case "bind":
                    try
                    {
                        if (2 == tokens.Length || 6 == tokens.Length)
                        {
                            uint port = Convert.ToUInt32(tokens[1]);
                            if (0 == port)
                            {
                                this.Output("Invalid Port Number");
                            }
                            else
                            {
                                SessionOpts opts = new SessionOpts(TrafficType.TRAFFIC_MESSAGES, false, ProximityType.PROXIMITY_ANY, TransportMaskType.TRANSPORT_ANY);
                                if (6 == tokens.Length)
                                {
                                    string[] optsInput = { tokens[2], tokens[3], tokens[4], tokens[5] };
                                    opts = this.GetSessionOpts(optsInput);
                                }

                                if (null != opts)
                                {
                                    this.sessionOps.DoBind(port, opts);
                                }
                                else
                                {
                                    this.Output("Usage: bind <port> [traffic] [isMultipoint] [proximity] [transports]");
                                }
                            }
                        }
                        else
                        {
                            this.Output("Usage: bind <port> [traffic] [isMultipoint] [proximity] [transports]");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Port Number");
                    }

                    break;

                case "unbind":
                    try
                    {
                        if (2 == tokens.Length)
                        {
                            uint port = Convert.ToUInt32(tokens[1]);
                            if (0 == port)
                            {
                                this.Output("Invalid Port Number");
                            }
                            else
                            {
                                this.sessionOps.DoUnbind(port);
                            }
                        }
                        else
                        {
                            this.Output("Usage: unbind <port>");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Port Number");
                    }

                    break;

                case "advertise":
                    try
                    {
                        if ((2 == tokens.Length || 3 == tokens.Length) && string.Empty != tokens[1])
                        {
                            TransportMaskType transport = TransportMaskType.TRANSPORT_ANY;
                            if (3 == tokens.Length)
                            {
                                uint tp = Convert.ToUInt32(tokens[2]);
                                transport = (TransportMaskType)tp;
                            }

                            this.sessionOps.DoAdvertise(tokens[1], transport);
                        }
                        else
                        {
                            this.Output("Usage: advertise <name> [transports]");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Transport Mask");
                    }

                    break;

                case "canceladvertise":
                    try
                    {
                        if ((2 == tokens.Length || 3 == tokens.Length) && string.Empty != tokens[1])
                        {
                            TransportMaskType transport = TransportMaskType.TRANSPORT_ANY;
                            if (3 == tokens.Length)
                            {
                                uint tp = Convert.ToUInt32(tokens[2]);
                                transport = (TransportMaskType)tp;
                            }

                            this.sessionOps.DoCancelAdvertise(tokens[1], transport);
                        }
                        else
                        {
                            this.Output("Usage: canceladvertise <name> [transports]");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Transport Mask");
                    }

                    break;

                case "find":
                    if (2 == tokens.Length && string.Empty != tokens[1])
                    {
                        this.sessionOps.DoFind(tokens[1]);
                    }
                    else
                    {
                        this.Output("Usage: find <name_prefix>");
                    }

                    break;

                case "cancelfind":
                    if (2 == tokens.Length && string.Empty != tokens[1])
                    {
                        this.sessionOps.DoCancelFind(tokens[1]);
                    }
                    else
                    {
                        this.Output("Usage: cancelfind <name_prefix>");
                    }

                    break;

                case "list":
                    this.sessionOps.DoList();
                    break;

                case "join":
                    try
                    {
                        if ((3 == tokens.Length || 7 == tokens.Length) && string.Empty != tokens[1])
                        {
                            uint port = Convert.ToUInt32(tokens[2]);
                            if (0 == port)
                            {
                                this.Output("Invalid Port Number");
                            }
                            else
                            {
                                SessionOpts opts = new SessionOpts(TrafficType.TRAFFIC_MESSAGES, false, ProximityType.PROXIMITY_ANY, TransportMaskType.TRANSPORT_ANY);
                                if (7 == tokens.Length)
                                {
                                    string[] optsInput = { tokens[3], tokens[4], tokens[5], tokens[6] };
                                    opts = this.GetSessionOpts(optsInput);
                                }

                                if (null != opts)
                                {
                                    this.sessionOps.DoJoinAsync(tokens[1], port, opts);
                                }
                                else
                                {
                                    this.Output("Usage: join <name> <port> [traffic] [isMultipoint] [proximity] [transports]");
                                }
                            }
                        }
                        else
                        {
                            this.Output("Usage: join <name> <port> [traffic] [isMultipoint] [proximity] [transports]");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Port Number");
                    }

                    break;

                case "leave":
                    if (2 == tokens.Length)
                    {
                        uint sessionId = this.GetSessionId(tokens[1]);
                        if (sessionId == 0)
                        {
                            this.Output("Invalid Session ID");
                        }
                        else
                        {
                            this.sessionOps.DoLeave(sessionId);
                        }
                    }
                    else
                    {
                        this.Output("Usage: leave <sessionId>");
                    }

                    break;

                case "timeout":
                    try
                    {
                        if (3 == tokens.Length)
                        {
                            uint sessionId = this.GetSessionId(tokens[1]);
                            uint timeOut   = Convert.ToUInt32(tokens[2]);
                            if (sessionId == 0 || timeOut == 0)
                            {
                                this.Output("Usage: timeout <sessionId> <timeout>");
                            }
                            else
                            {
                                this.sessionOps.DoSetLinkTimeoutAsync(sessionId, timeOut);
                            }
                        }
                        else
                        {
                            this.Output("Usage: timeout <sessionId> <timeout>");
                        }
                    }
                    catch (Exception ex)
                    {
                        string errMsg = ex.Message;
                        this.Output("Invalid Timeout argument");
                    }

                    break;

                case "chat":
                    byte flags1 = (byte)AllJoyn.AllJoynFlagType.ALLJOYN_FLAG_GLOBAL_BROADCAST;
                    if (3 <= tokens.Length)
                    {
                        uint   sessionId = this.GetSessionId(tokens[1]);
                        string msg       = string.Join(" ", tokens, 2, tokens.Length - 2);
                        if (sessionId == 0)
                        {
                            this.Output("Usage: chat <sessionId> <msg>");
                        }
                        else
                        {
                            this.sessionOps.SendChatSignal(sessionId, msg, flags1);
                        }
                    }
                    else
                    {
                        this.Output("Usage: chat <sessionId> <msg>");
                    }

                    break;

                case "cchat":
                    byte flags2 = (byte)AllJoyn.AllJoynFlagType.ALLJOYN_FLAG_COMPRESSED;
                    if (3 <= tokens.Length)
                    {
                        uint   sessionId = this.GetSessionId(tokens[1]);
                        string msg       = string.Join(" ", tokens, 2, tokens.Length - 2);
                        if (sessionId == 0 || msg == string.Empty)
                        {
                            this.Output("Usage: cchat <sessionId> <msg>");
                        }
                        else
                        {
                            this.sessionOps.SendChatSignal(sessionId, msg, flags2);
                        }
                    }
                    else
                    {
                        this.Output("Usage: cchat <sessionId> <msg>");
                    }

                    break;

                case "schat":
                    byte flags3 = (byte)AllJoyn.AllJoynFlagType.ALLJOYN_FLAG_SESSIONLESS;
                    if (2 <= tokens.Length)
                    {
                        string msg = string.Join(" ", tokens, 1, tokens.Length - 1);
                        if (msg == string.Empty)
                        {
                            this.Output("Usage: schat <msg>");
                        }
                        else
                        {
                            this.sessionOps.SendSessionlessChatSignal(msg, flags3);
                        }
                    }
                    else
                    {
                        this.Output("Usage: schat <msg>");
                    }

                    break;

                case "addmatch":
                    if (2 <= tokens.Length)
                    {
                        string msg = string.Join(" ", tokens, 1, tokens.Length - 1);
                        if (msg == string.Empty)
                        {
                            this.Output("Usage: addmatch <filter>");
                        }
                        else
                        {
                            this.sessionOps.AddRule(msg);
                        }
                    }
                    else
                    {
                        this.Output("Usage: addmatch <filter>");
                    }

                    break;

                case "chatecho":
                    if (2 == tokens.Length)
                    {
                        if (tokens[1] == "on")
                        {
                            this.sessionOps.SetChatEcho(true);
                        }
                        else if (tokens[1] == "off")
                        {
                            this.sessionOps.SetChatEcho(false);
                        }
                        else
                        {
                            this.Output("Usage: chatecho [on|off]");
                        }
                    }
                    else
                    {
                        this.Output("Usage: chatecho [on|off]");
                    }

                    break;

                case "exit":
                    this.sessionOps.Exit();
                    break;

                case "help":
                    this.sessionOps.PrintHelp();
                    break;

                default:
                    this.Output("Unknown command: " + tokens[0]);
                    break;
                }

                this.btnUpDown = true;
                await Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    () =>
                {
                    this.input.Text = string.Empty;
                });
            }
            else if (e.Key == Windows.System.VirtualKey.Enter && string.Empty == this.input.Text && !this.btnUpDown)
            {
                this.Output(">>>>>");
                this.btnUpDown = true;
            }
        }
예제 #32
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known name
 /// that this attachment has registered interest in via a DBus call to org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
 private void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (this.hostPage != null)
     {
         this.hostPage.AddChannelName(name);
     }
 }
예제 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiscoveryInfo"/> class
 /// </summary>
 /// <param name="peer">Peer's name that was discovered</param>
 /// <param name="transport">Transport which the name was discovered on</param>
 public DiscoveryInfo(string peer, TransportMaskType transport)
 {
     this.PeerName = peer;
     this.Transport = transport;
 }
예제 #34
0
        /// <summary>
        /// Called by the bus when an external bus is discovered that is advertising a well-known 
        /// name that this attachment has registered interest in via a DBus call to 
        /// org.alljoyn.Bus.FindAdvertisedName
        /// </summary>
        /// <param name="name">A well known name that the remote bus is advertising.</param>
        /// <param name="transport">Transport that received the advertisement.</param>
        /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName 
        /// that triggered this callback.</param>
        public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
        {
            this.mutex.WaitOne();
            bool ret = this.foundAvertisedName;
            this.foundAvertisedName = true;
            this.mutex.ReleaseMutex();
            if (ret)
            {
                this.DebugPrint("Will not form a session with(name=" + name + ", prefix=" + namePrefix +
                    ") because we already joined a session.");
                return;
            }

            this.DebugPrint("FoundAdvertisedName(name=" + name + ", prefix=" + namePrefix + ")");
            this.stressOp.DiscoveredName = name;
            this.foundName.Set();
        }
예제 #35
0
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     lock (FoundNames)
     {
         FoundNames.Add(name);
         this.FoundCount++;
         if (this.FoundCount == 4)
         {
             gotAllNames.Set();
         }
     }
 }
예제 #36
0
 void BusListenerFoundAdvertisedName(string wkn, TransportMaskType transport, string namePrefix)
 {
 }
예제 #37
0
 public void BusListenerLostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     lostAdvertisedName.Set();
 }
예제 #38
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known name
 /// that this attachment has registered interest in via a DBus call to org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName that triggered this callback.</param>
 private void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (this.FoundAdvertisedName != null)
     {
         this.FoundAdvertisedName(name, transport, namePrefix);
     }
 }
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known 
 /// name that this attachment has registered interest in via a DBus call to 
 /// org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName 
 /// that triggered this callback.</param>
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     if (name.CompareTo(BasicClientGlobals.WellKnownServiceName) == 0)
     {
         App.OutputLine("Found Advertised Name (Name=" + name + "\tPrefix=" + namePrefix + ")");
         this.foundName.Set();
     }
 }
예제 #40
0
 /// <summary>
 /// Handler for the FoundAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 private void Listeners_FoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.ButtonRunClient.IsEnabled = true;
     this.OutputLine("Found advertised name and enabled Run button.");
 }
예제 #41
0
 /// <summary>
 /// Advertise the well known name 'name' for client to discover
 /// </summary>
 /// <param name="name">Well known name to advertise</param>
 /// <param name="transport">Transport type for which to advertise the name over</param>
 public void DoAdvertise(string name, TransportMaskType transport)
 {
     try
     {
         lock (this.requestedNames)
         {
             if (this.requestedNames.Contains(name))
             {
                 this.busAtt.AdvertiseName(name, transport);
                 lock (this.advertisedNames)
                 {
                     this.advertisedNames.Add(name);
                 }
             }
             else
             {
                 this.mainPage.Output(name + " must first be requested from the bus before it can be advertised");
             }
         }
     }
     catch (Exception ex)
     {
         var errMsg = AllJoynException.GetErrorMessage(ex.HResult);
         this.mainPage.Output("BusAttachment.AdvertiseName(" + name + ", " + (uint)transport + ") failed: " + errMsg);
     }
 }
예제 #42
0
 /// <summary>
 /// Handler for the LostAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 private void Listeners_LostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.ButtonRunClient.IsEnabled = false;
     this.BusObject = null;
     this.OutputLine("Lost advertised name and disabled Run button.");
 }
예제 #43
0
 void BusListenerFoundAdvertisedName(string wkn, TransportMaskType transport, string namePrefix)
 {
 }
예제 #44
0
 /// <summary>
 /// Called by the bus when an external bus is discovered that is advertising a well-known
 /// name that this attachment has registered interest in via a DBus call to
 /// org.alljoyn.Bus.FindAdvertisedName
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this callback.</param>
 public void BusListenerFoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     this.sessionOps.Output("Discovered name : " + name);
     this.sessionOps.FoundAdvertisedName(name, transport);
 }
예제 #45
0
 /// <summary>
 /// Handler for the FoundAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 private void Listeners_FoundAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     throw new NotImplementedException();
 }
예제 #46
0
 /// <summary>
 /// Handler for the LostAdvertisedName event.
 /// </summary>
 /// <param name="name">A well known name that the remote bus is advertising.</param>
 /// <param name="transport">Transport that received the advertisement.</param>
 /// <param name="namePrefix">The well-known name prefix used in call to FindAdvertisedName
 /// that triggered this event.</param>
 public void Listeners_LostAdvertisedName(string name, TransportMaskType transport, string namePrefix)
 {
     App.OutputLine("Lost advertised name in App handler.");
 }