def __init__(self): super(AllPlayController, self).__init__() self.alljoyn = AllJoyn() alljoyn.RouterInit() self.player = None self.queue = [] self.g_bus = BusAttachment.BusAttachment("AllPlayerApp", True) self.g_bus.Start() try: self.g_bus.Connect(None) except QStatusException: print "Have you got the daemon running ?" sys.exit(1) self.aboutListener = MyAboutListener(self.g_bus) self.g_bus.RegisterAboutListener(self.aboutListener) self.g_bus.WhoImplementsInterfaces([SERVICE_NAME]) # Wait for join session to complete t = 0 while t < 10.0: if len(self.aboutListener.devices) >= 3: break time.sleep(0.1) t += 0.1 self.allplayers = {} for p in self.aboutListener.devices.values(): print "session_id", MyAboutListener.session_id self.allplayers[p['id']] = AllPlayer( self.g_bus, p['busname'], p['session_id'], p['name'], p['id'])
proxyBusObject = ProxyBusObject.ProxyBusObject(g_bus, busName, '/About', sessionId) try: proxyBusObject.IntrospectRemoteObject() iface = proxyBusObject.GetInterface("org.alljoyn.About") print iface.Introspect() except QStatusException, ex: print "Failed to introspect remote object." if __name__ == "__main__": # Install SIGINT handler so Ctrl + C deallocates memory properly alljoyn = AllJoyn() print "AllJoyn Library version:", alljoyn.Version print "AllJoyn Library build info:", alljoyn.BuildInfo alljoyn.RouterInit() signal.signal(signal.SIGINT, signal_handler) # Create message bus g_bus = alljoyn.BusAttachment.BusAttachment("AboutServiceTest", True) # Start the msg bus g_bus.Start() try:
def OnNameOwnerChangedCallBack(self, context, bus_name, previous_owner, new_owner): if new_owner and bus_name == SERVICE_NAME: print "NameOwnerChanged: name=%s, oldOwner=%s, newOwner=%s." % (bus_name, previous_owner, new_owner) def CreateBasicServiceInterface(bus_attachment): iface = bus_attachment.CreateInterface(INTERFACE_NAME) ##AddMember(self, message_type, name, inputSig, outSig, argNames, annotation): #iface.AddMember(Message.MessageType.ALLJOYN_MESSAGE_METHOD_CALL, "GetCurrentItemUrl", None, "s", None, 0) iface.AddMethod("cat", "ss", "s", "inStr1,inStr2,outStr", 0, None) iface.Activate() if __name__ == "__main__": alljoyn = AllJoyn() signal.signal(signal.SIGINT, signal_handler) myListener = MyListener() g_bus = BusAttachment.BusAttachment("myApp", True) g_bus.RegisterBusListener(myListener.busListener) CreateBasicServiceInterface(g_bus) basicServiceObject = BasicServiceObject(g_bus, SERVICE_PATH) g_bus.RegisterBusObject(basicServiceObject)
def setUp(self): self.alljoyn = AllJoyn()