Beispiel #1
0
        public void createAndAdvertiseSession(string name)
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.OK;
            myAdvertisedName = SERVICE_NAME + "._" + name + "_" + msgBus.GlobalGUIDString;

            if (status)
            {
                status = msgBus.RequestName(myAdvertisedName,
                                            AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if (!status)
                {
                    chatText = "Chat RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")\n" + chatText;
                    Debug.Log("Chat RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")");
                }
            }


            // Create session
            opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false,
                                           AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if (status)
            {
                ushort sessionPort = SERVICE_PORT;
                sessionPortListener = new MySessionPortListener();
                status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener);
                if (!status || sessionPort != SERVICE_PORT)
                {
                    chatText = "Chat BindSessionPort failed (" + status + ")\n" + chatText;
                    Debug.Log("Chat BindSessionPort failed (" + status + ")");
                }
                chatText = "Chat BindSessionPort on port (" + sessionPort + ")\n" + chatText;
                Debug.Log("Chat BBindSessionPort on port (" + sessionPort + ")");;
            }

            // Advertise name
            if (status)
            {
                status = msgBus.AdvertiseName(myAdvertisedName, opts.Transports);
                if (!status)
                {
                    chatText = "Chat Failed to advertise name " + name + " (" + status + ")\n" + chatText;
                    Debug.Log("Chat Failed to advertise name " + name + " (" + status + ")");
                }
            }

            status = msgBus.FindAdvertisedName(SERVICE_NAME);
            if (!status)
            {
                chatText = "Chat org.alljoyn.Bus.FindAdvertisedName failed.\n" + chatText;
                Debug.Log("Chat org.alljoyn.Bus.FindAdvertisedName failed.");
            }
        }
Beispiel #2
0
        public BasicServer()
        {
            // Create message bus
            msgBus = new AllJoyn.BusAttachment("myApp", true);

            // Add org.alljoyn.Bus.method_sample interface
            AllJoyn.QStatus status = msgBus.CreateInterface(INTERFACE_NAME, false, out testIntf);
            if (status)
            {
                Console.WriteLine("Server Interface Created.");
                testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr");
                testIntf.Activate();
            }
            else
            {
                Console.WriteLine("Failed to create interface 'org.alljoyn.Bus.method_sample'");
            }

            // Create a bus listener
            busListener = new MyBusListener();
            if (status)
            {
                msgBus.RegisterBusListener(busListener);
                Console.WriteLine("Server BusListener Registered.");
            }

            // Set up bus object
            testObj = new TestBusObject(msgBus, SERVICE_PATH);

            // Start the msg bus
            if (status)
            {
                status = msgBus.Start();
                if (status)
                {
                    Console.WriteLine("Server BusAttachment started.");
                    msgBus.RegisterBusObject(testObj);

                    status = msgBus.Connect(connectArgs);
                    if (status)
                    {
                        Console.WriteLine("Server BusAttchement connected to " + connectArgs);
                    }
                    else
                    {
                        Console.WriteLine("Server BusAttachment::Connect(" + connectArgs + ") failed.");
                    }
                }
                else
                {
                    Console.WriteLine("Server BusAttachment.Start failed.");
                }
            }

            // Request name
            if (status)
            {
                status = msgBus.RequestName(SERVICE_NAME,
                                            AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if (!status)
                {
                    Console.WriteLine("Server RequestName({0}) failed (status={1})", SERVICE_NAME, status);
                }
            }

            // Create session
            AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false,
                                                               AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if (status)
            {
                ushort sessionPort = SERVICE_PORT;
                sessionPortListener = new MySessionPortListener();
                status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener);
                if (!status || sessionPort != SERVICE_PORT)
                {
                    Console.WriteLine("Server BindSessionPort failed ({0})", status);
                }
            }

            // Advertise name
            if (status)
            {
                status = msgBus.AdvertiseName(SERVICE_NAME, opts.Transports);
                if (!status)
                {
                    Console.WriteLine("Server Failed to advertise name {0} ({1})", SERVICE_NAME, status);
                }
            }
        }
        public void TestSessionJoined()
        {
            AllJoyn.QStatus status = AllJoyn.QStatus.FAIL;

            // create+start+connect bus attachment
            AllJoyn.BusAttachment servicebus = null;
            servicebus = new AllJoyn.BusAttachment("SessionTestService", true);
            Assert.NotNull(servicebus);

            status = servicebus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = servicebus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Create session
            AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(
                AllJoyn.SessionOpts.TrafficType.Messages, false,
                AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            ushort sessionPort = SERVICE_PORT;

            // create the session port listener
            AllJoyn.SessionPortListener sessionPortListener = new TestSessionPortListener(this);

            // bind to the session port
            status = servicebus.BindSessionPort(ref sessionPort, opts, sessionPortListener);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // request name
            status = servicebus.RequestName(OBJECT_NAME, AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // Advertise name
            status = servicebus.AdvertiseName(OBJECT_NAME, opts.Transports);
            Assert.Equal(AllJoyn.QStatus.OK, status);

            ///////////////////////////////////////////////////////////
            foundAdvertisedNameFlag = false;
            acceptSessionJoinerFlag = false;
            sessionJoinedFlag       = false;

            // try to join the session & verify callbacks are called
            AllJoyn.BusAttachment bus = null;
            bus = new AllJoyn.BusAttachment("SessionTest", true);
            Assert.NotNull(bus);

            status = bus.Start();
            Assert.Equal(AllJoyn.QStatus.OK, status);

            status = bus.Connect(AllJoynTestCommon.GetConnectSpec());
            Assert.Equal(AllJoyn.QStatus.OK, status);

            // register the bus listener
            AllJoyn.BusListener busListener = new TestBusListener(this);
            bus.RegisterBusListener(busListener);

            // find the advertised name from the "servicebus"
            status = bus.FindAdvertisedName(OBJECT_NAME);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            EventWaitHandle ewh = new EventWaitHandle(false, EventResetMode.AutoReset, "FoundAdvertisedName");

            ewh.WaitOne(MaxWaitTime);
            Assert.Equal(true, foundAdvertisedNameFlag);

            // try to join & verify that the sessionedJoined callback was called
            uint sSessionId;

            status = bus.JoinSession(OBJECT_NAME, SERVICE_PORT, null, out sSessionId, opts);
            Assert.Equal(AllJoyn.QStatus.OK, status);
            ewh = new EventWaitHandle(false, EventResetMode.AutoReset, "SessionJoined");
            ewh.WaitOne(MaxWaitTime);
            Assert.Equal(true, acceptSessionJoinerFlag);
            Assert.Equal(true, sessionJoinedFlag);
            servicebus.ReleaseName(OBJECT_NAME);
            servicebus.Dispose();
            bus.Dispose();
        }
        public BasicServer()
        {
            serverText = "";
            // Create message bus
            msgBus = new AllJoyn.BusAttachment("myApp", true);

            // Add org.alljoyn.Bus.method_sample interface
            AllJoyn.QStatus status = msgBus.CreateInterface(INTERFACE_NAME, false, out testIntf);
            if (status)
            {
                serverText += "Server Interface Created.\n";
                Debug.Log("Server Interface Created.");
                testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr");
                testIntf.Activate();
            }
            else
            {
                serverText += "Failed to create interface 'org.alljoyn.Bus.method_sample'\n";
                Debug.Log("Failed to create interface 'org.alljoyn.Bus.method_sample'");
            }

            // Create a bus listener
            busListener = new MyBusListener();
            if (status)
            {
                msgBus.RegisterBusListener(busListener);
                serverText += "Server BusListener Registered.\n";
                Debug.Log("Server BusListener Registered.");
            }

            // Set up bus object
            testObj = new TestBusObject(msgBus, SERVICE_PATH);
            // Start the msg bus
            if (status)
            {
                status = msgBus.Start();
                if (status)
                {
                    serverText += "Server BusAttachment started.\n";
                    Debug.Log("Server BusAttachment started.");
                    msgBus.RegisterBusObject(testObj);

                    for (int i = 0; i < connectArgs.Length; ++i)
                    {
                        status = msgBus.Connect(connectArgs [i]);
                        if (status)
                        {
                            serverText += "BusAttchement.Connect(" + connectArgs [i] + ") SUCCEDED.\n";
                            Debug.Log("BusAttchement.Connect(" + connectArgs [i] + ") SUCCEDED.");
                            break;
                        }
                        else
                        {
                            serverText += "BusAttachment.Connect(" + connectArgs [i] + ") failed.\n";
                            Debug.Log("BusAttachment.Connect(" + connectArgs [i] + ") failed.");
                        }
                    }
                    if (!status)
                    {
                        serverText += "BusAttachment.Connect failed.\n";
                        Debug.Log("BusAttachment.Connect failed.");
                    }
                }
                else
                {
                    serverText += "Server BusAttachment.Start failed.\n";
                    Debug.Log("Server BusAttachment.Start failed.");
                }
            }

            // Request name
            if (status)
            {
                status = msgBus.RequestName(SERVICE_NAME,
                                            AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if (!status)
                {
                    serverText += "Server RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")\n";
                    Debug.Log("Server RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")");
                }
            }

            // Create session
            opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, true,
                                           AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if (status)
            {
                ushort sessionPort = SERVICE_PORT;
                sessionPortListener = new MySessionPortListener();
                status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener);
                if (!status || sessionPort != SERVICE_PORT)
                {
                    serverText += "Server BindSessionPort failed (" + status + ")\n";
                    Debug.Log("Server BindSessionPort failed (" + status + ")");
                }
            }

            // Advertise name
            if (status)
            {
                status = msgBus.AdvertiseName(SERVICE_NAME, opts.Transports);
                if (!status)
                {
                    serverText += "Server Failed to advertise name " + SERVICE_NAME + " (" + status + ")\n";
                    Debug.Log("Server Failed to advertise name " + SERVICE_NAME + " (" + status + ")");
                }
            }
            serverText += "Completed BasicService Constructor\n";
            Debug.Log("Completed BasicService Constructor");
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            Console.WriteLine("AllJoyn Library version: " + AllJoyn.GetVersion());
            Console.WriteLine("AllJoyn Library buildInfo: " + AllJoyn.GetBuildInfo());

            // Create message bus
            sMsgBus = new AllJoyn.BusAttachment("myApp", true);

            // Add org.alljoyn.Bus.method_sample interface
            AllJoyn.InterfaceDescription testIntf;
            AllJoyn.QStatus status = sMsgBus.CreateInterface(INTERFACE_NAME, out testIntf);
            if (status)
            {
                Console.WriteLine("Interface Created.");
                testIntf.AddMember(AllJoyn.Message.Type.MethodCall, "cat", "ss", "s", "inStr1,inStr2,outStr");
                testIntf.Activate();
            }
            else
            {
                Console.WriteLine("Failed to create interface 'org.alljoyn.Bus.method_sample'");
            }

            // Create a bus listener
            sBusListener = new MyBusListener();
            if (status)
            {
                sMsgBus.RegisterBusListener(sBusListener);
                Console.WriteLine("BusListener Registered.");
            }

            // Set up bus object
            TestBusObject testObj = new TestBusObject(sMsgBus, SERVICE_PATH);

            // Start the msg bus
            if (status)
            {
                status = sMsgBus.Start();
                if (status)
                {
                    Console.WriteLine("BusAttachment started.");
                    sMsgBus.RegisterBusObject(testObj);

                    for (int i = 0; i < connectArgs.Length; ++i)
                    {
                        status = sMsgBus.Connect(connectArgs[i]);
                        if (status)
                        {
                            Console.WriteLine("BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED.");
                            break;
                        }
                        else
                        {
                            Console.WriteLine("BusAttachment.Connect(" + connectArgs[i] + ") failed.");
                        }
                    }
                    if (!status)
                    {
                        Console.WriteLine("BusAttachment.Connect failed.");
                    }
                }
                else
                {
                    Console.WriteLine("BusAttachment.Start failed.");
                }
            }

            // Request name
            if (status)
            {
                status = sMsgBus.RequestName(SERVICE_NAME,
                                             AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if (!status)
                {
                    Console.WriteLine("RequestName({0}) failed (status={1})", SERVICE_NAME, status);
                }
            }

            // Create session
            AllJoyn.SessionOpts opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false,
                                                               AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if (status)
            {
                ushort sessionPort = SERVICE_PORT;
                sSessionPortListener = new MySessionPortListener();
                status = sMsgBus.BindSessionPort(ref sessionPort, opts, sSessionPortListener);
                if (!status)
                {
                    Console.WriteLine("BindSessionPort failed ({0})", status);
                }
            }

            // Advertise name
            if (status)
            {
                status = sMsgBus.AdvertiseName(SERVICE_NAME, opts.Transports);
                if (!status)
                {
                    Console.WriteLine("Failed to advertise name {0} ({1})", SERVICE_NAME, status);
                }
            }

            if (status)
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(1);
                }
            }

            // Dispose of objects now
            sMsgBus.Dispose();
            sBusListener.Dispose();

            Console.WriteLine("basic server exiting with status {0} ({1})", status, status.ToString());
        }
Beispiel #6
0
        public void StartUp()
        {
            chatText       = "Starting AllJoyn\n\n\n" + chatText;
            AllJoynStarted = true;
            AllJoyn.QStatus status = AllJoyn.QStatus.OK;
            {
                chatText = "Creating BusAttachment\n" + chatText;
                // Create message bus
                msgBus = new AllJoyn.BusAttachment("myApp", true);

                // Add org.alljoyn.Bus.method_sample interface
                status = msgBus.CreateInterface(INTERFACE_NAME, false, out testIntf);
                if (status)
                {
                    chatText = "Chat Interface Created.\n" + chatText;
                    Debug.Log("Chat Interface Created.");
                    testIntf.AddSignal("chat", "s", "msg", 0);
                    testIntf.Activate();
                }
                else
                {
                    chatText = "Failed to create interface 'org.alljoyn.Bus.chat'\n" + chatText;
                    Debug.Log("Failed to create interface 'org.alljoyn.Bus.chat'");
                }

                // Create a bus listener
                busListener = new MyBusListener();
                if (status)
                {
                    msgBus.RegisterBusListener(busListener);
                    chatText = "Chat BusListener Registered.\n" + chatText;
                    Debug.Log("Chat BusListener Registered.");
                }


                if (testObj == null)
                {
                    testObj = new TestBusObject(msgBus, SERVICE_PATH);
                }

                // Start the msg bus
                if (status)
                {
                    status = msgBus.Start();
                    if (status)
                    {
                        chatText = "Chat BusAttachment started.\n" + chatText;
                        Debug.Log("Chat BusAttachment started.");

                        msgBus.RegisterBusObject(testObj);
                        for (int i = 0; i < connectArgs.Length; ++i)
                        {
                            chatText = "Chat Connect trying: " + connectArgs[i] + "\n" + chatText;
                            Debug.Log("Chat Connect trying: " + connectArgs[i]);
                            status = msgBus.Connect(connectArgs[i]);
                            if (status)
                            {
                                chatText = "BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED.\n" + chatText;
                                Debug.Log("BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED.");
                                connectedVal = connectArgs[i];
                                break;
                            }
                            else
                            {
                                chatText = "BusAttachment.Connect(" + connectArgs[i] + ") failed.\n" + chatText;
                                Debug.Log("BusAttachment.Connect(" + connectArgs[i] + ") failed.");
                            }
                        }
                        if (!status)
                        {
                            chatText = "BusAttachment.Connect failed.\n" + chatText;
                            Debug.Log("BusAttachment.Connect failed.");
                        }
                    }
                    else
                    {
                        chatText = "Chat BusAttachment.Start failed.\n" + chatText;
                        Debug.Log("Chat BusAttachment.Start failed.");
                    }
                }

                myAdvertisedName = SERVICE_NAME + "._" + msgBus.GlobalGUIDString;

                AllJoyn.InterfaceDescription.Member chatMember = testIntf.GetMember("chat");
                status = msgBus.RegisterSignalHandler(this.ChatSignalHandler, chatMember, null);
                if (!status)
                {
                    chatText = "Chat Failed to add signal handler " + status + "\n" + chatText;
                    Debug.Log("Chat Failed to add signal handler " + status);
                }
                else
                {
                    chatText = "Chat add signal handler " + status + "\n" + chatText;
                    Debug.Log("Chat add signal handler " + status);
                }

                status = msgBus.AddMatch("type='signal',member='chat'");
                if (!status)
                {
                    chatText = "Chat Failed to add Match " + status.ToString() + "\n" + chatText;
                    Debug.Log("Chat Failed to add Match " + status.ToString());
                }
                else
                {
                    chatText = "Chat add Match " + status.ToString() + "\n" + chatText;
                    Debug.Log("Chat add Match " + status.ToString());
                }
            }

            // Request name
            if (status)
            {
                status = msgBus.RequestName(myAdvertisedName,
                                            AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if (!status)
                {
                    chatText = "Chat RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")\n" + chatText;
                    Debug.Log("Chat RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")");
                }
            }

            // Create session
            opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false,
                                           AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if (status)
            {
                ushort sessionPort = SERVICE_PORT;
                sessionPortListener = new MySessionPortListener();
                status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener);
                if (!status || sessionPort != SERVICE_PORT)
                {
                    chatText = "Chat BindSessionPort failed (" + status + ")\n" + chatText;
                    Debug.Log("Chat BindSessionPort failed (" + status + ")");
                }
                chatText = "Chat BindSessionPort on port (" + sessionPort + ")\n" + chatText;
                Debug.Log("Chat BBindSessionPort on port (" + sessionPort + ")");;
            }

            // Advertise name
            if (status)
            {
                status = msgBus.AdvertiseName(myAdvertisedName, opts.Transports);
                if (!status)
                {
                    chatText = "Chat Failed to advertise name " + myAdvertisedName + " (" + status + ")\n" + chatText;
                    Debug.Log("Chat Failed to advertise name " + myAdvertisedName + " (" + status + ")");
                }
            }

            status = msgBus.FindAdvertisedName(SERVICE_NAME);
            if (!status)
            {
                chatText = "Chat org.alljoyn.Bus.FindAdvertisedName failed.\n" + chatText;
                Debug.Log("Chat org.alljoyn.Bus.FindAdvertisedName failed.");
            }

            Debug.Log("Completed ChatService Constructor");
        }
Beispiel #7
0
        public void StartUp()
        {
            //Debug.LogError("Starting AllJoyn");
            AllJoynStarted = true;
            AllJoyn.QStatus status = AllJoyn.QStatus.OK;
            {
                //Debug.LogError("Creating BusAttachment");
                msgBus = new AllJoyn.BusAttachment("myApp", true);

                status = msgBus.CreateInterface(INTERFACE_NAME, false, out testIntf);
                if (status)
                {
                    //Debug.LogError("Interface Created.");
                    testIntf.AddSignal("player", "sddddbb", "playerPoints", 0);
                    testIntf.AddSignal("enemyInit", "ssdddd", "enemyPoints", 0);
                    testIntf.AddSignal("enemyAgro", "sss", "enemyPoints1", 0);
                    testIntf.AddSignal("enemyHP", "ssd", "enemyPoints2", 0);
                    testIntf.Activate();
                }
                else
                {
                    //Debug.LogError("Failed to create interface 'org.alljoyn.Bus.chat'");
                }

                busListener = new MyBusListener();
                if (status)
                {
                    msgBus.RegisterBusListener(busListener);
                    //Debug.LogError("BusListener Registered.");
                }


                if (testObj == null)
                {
                    testObj = new TestBusObject(msgBus, SERVICE_PATH);
                }

                if (status)
                {
                    status = msgBus.Start();
                    if (status)
                    {
                        //Debug.LogError("BusAttachment started.");

                        msgBus.RegisterBusObject(testObj);
                        for (int i = 0; i < connectArgs.Length; ++i)
                        {
                            //Debug.LogError("Connect trying: " + connectArgs[i]);
                            status = msgBus.Connect(connectArgs[i]);
                            if (status)
                            {
                                //Debug.LogError("BusAttchement.Connect(" + connectArgs[i] + ") SUCCEDED.");
                                connectedVal = connectArgs[i];
                                break;
                            }
                            else
                            {
                                //Debug.LogError("BusAttachment.Connect(" + connectArgs[i] + ") failed.");
                            }
                        }
                        if (!status)
                        {
                            //Debug.LogError("BusAttachment.Connect failed.");
                        }
                    }
                    else
                    {
                        //Debug.LogError("BusAttachment.Start failed.");
                    }
                }

                myAdvertisedName = SERVICE_NAME + "._" + msgBus.GlobalGUIDString + playerNick;



                AllJoyn.InterfaceDescription.Member playerMember = testIntf.GetMember("player");
                status = msgBus.RegisterSignalHandler(this.PlayerSignalHandler, playerMember, null);
                if (!status)
                {
                    //Debug.LogError("Failed to add vector signal handler " + status);
                }
                else
                {
                    //Debug.LogError("add vector signal handler " + status);
                }

                AllJoyn.InterfaceDescription.Member enemyInitMember = testIntf.GetMember("enemyInit");
                status = msgBus.RegisterSignalHandler(this.EnemyInitSignalHandler, enemyInitMember, null);
                if (!status)
                {
                    Debug.LogError("Failed to add vector signal handler " + status);
                }
                else
                {
                    //Debug.LogError("add vector signal handler " + status);
                }

                AllJoyn.InterfaceDescription.Member enemyAgroMember = testIntf.GetMember("enemyAgro");
                status = msgBus.RegisterSignalHandler(this.EnemyAgroSignalHandler, enemyAgroMember, null);
                if (!status)
                {
                    Debug.LogError("Failed to add vector signal handler " + status);
                }
                else
                {
                    //Debug.LogError("add vector signal handler " + status);
                }

                AllJoyn.InterfaceDescription.Member enemyHPMember = testIntf.GetMember("enemyHP");
                status = msgBus.RegisterSignalHandler(this.EnemyHPSignalHandler, enemyHPMember, null);
                if (!status)
                {
                    Debug.LogError("Failed to add vector signal handler " + status);
                }
                else
                {
                    //Debug.LogError("add vector signal handler " + status);
                }


                status = msgBus.AddMatch("type='signal',interface='org.alljoyn.bus.multi'");
                if (!status)
                {
                    Debug.LogError("Failed to add vector Match " + status.ToString());
                }
                else
                {
                    //Debug.LogError("add vector Match " + status.ToString());
                }
            }

            if (status)
            {
                status = msgBus.RequestName(myAdvertisedName,
                                            AllJoyn.DBus.NameFlags.ReplaceExisting | AllJoyn.DBus.NameFlags.DoNotQueue);
                if (!status)
                {
                    Debug.LogError("RequestName(" + SERVICE_NAME + ") failed (status=" + status + ")");
                }
            }

            opts = new AllJoyn.SessionOpts(AllJoyn.SessionOpts.TrafficType.Messages, false,
                                           AllJoyn.SessionOpts.ProximityType.Any, AllJoyn.TransportMask.Any);
            if (status)
            {
                ushort sessionPort = SERVICE_PORT;
                sessionPortListener = new MySessionPortListener(this);
                status = msgBus.BindSessionPort(ref sessionPort, opts, sessionPortListener);
                if (!status || sessionPort != SERVICE_PORT)
                {
                    Debug.LogError("BindSessionPort failed (" + status + ")");
                }
                //Debug.LogError("BBindSessionPort on port (" + sessionPort + ")"); ;
            }

            if (status)
            {
                status = msgBus.AdvertiseName(myAdvertisedName, opts.Transports);
                if (!status)
                {
                    Debug.LogError("Failed to advertise name " + myAdvertisedName + " (" + status + ")");
                }
            }

            status = msgBus.FindAdvertisedName(SERVICE_NAME);
            if (!status)
            {
                Debug.LogError("org.alljoyn.Bus.FindAdvertisedName failed.");
            }
        }