def constructAcceptor(log, ssl, jsonBridge): sslctx = DEAFAULT_SSL_CONTEXT if ssl else None reactor = Reactor() acceptor = MultiProtocolAcceptor(reactor, "127.0.0.1", 0, sslctx) cif = FakeClientIf() xml_binding = BindingXMLRPC(cif, cif.log) xml_binding.start() xmlDetector = XmlDetector(xml_binding) acceptor.add_detector(xmlDetector) json_binding = BindingJsonRpc(jsonBridge) json_binding.start() stompDetector = StompDetector(json_binding) acceptor.add_detector(stompDetector) thread = threading.Thread( target=reactor.process_requests, name='Detector thread', ) thread.setDaemon(True) thread.start() try: yield acceptor finally: acceptor.stop() json_binding.stop() xml_binding.stop()
def constructAcceptor(log, ssl, jsonBridge, dest=LEGACY_SUBSCRIPTION_ID_RESPONSE): sslctx = DEAFAULT_SSL_CONTEXT if ssl else None reactor = Reactor() acceptor = MultiProtocolAcceptor( reactor, "127.0.0.1", 0, sslctx, ) scheduler = schedule.Scheduler(name="test.Scheduler", clock=utils.monotonic_time) scheduler.start() json_binding = BindingJsonRpc(jsonBridge, defaultdict(list), 60, scheduler) json_binding.start() cif = FakeClientIf(json_binding, dest) xml_binding = BindingXMLRPC(cif, cif.log) xml_binding.start() xmlDetector = XmlDetector(xml_binding) acceptor.add_detector(xmlDetector) jsonBridge.cif = cif stompDetector = StompDetector(json_binding) acceptor.add_detector(stompDetector) thread = threading.Thread(target=reactor.process_requests, name='Detector thread') thread.setDaemon(True) thread.start() try: yield acceptor finally: acceptor.stop() json_binding.stop() xml_binding.stop() scheduler.stop(wait=False)
def _prepareXMLRPCBinding(self): if config.getboolean('vars', 'xmlrpc_enable'): try: from rpc.bindingxmlrpc import BindingXMLRPC from rpc.bindingxmlrpc import XmlDetector except ImportError: self.log.error('Unable to load the xmlrpc server module. ' 'Please make sure it is installed.') else: xml_binding = BindingXMLRPC(self, self.log) self.bindings['xmlrpc'] = xml_binding xml_detector = XmlDetector(xml_binding) self._acceptor.add_detector(xml_detector)