def constructAcceptor(log, ssl, jsonBridge): sslctx = DEAFAULT_SSL_CONTEXT if ssl else None acceptor = MultiProtocolAcceptor("127.0.0.1", 0, sslctx) cif = FakeClientIf() _, port = acceptor._socket.getsockname() xml_binding = BindingXMLRPC(cif, cif.log, port) 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=acceptor.serve_forever, name='Detector thread') thread.setDaemon(True) thread.start() try: yield acceptor finally: acceptor.stop() json_binding.stop() xml_binding.stop()
def _prepareXMLRPCBinding(self, port): 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, port) self.bindings['xmlrpc'] = xml_binding xml_detector = XmlDetector(xml_binding) self._acceptor.add_detector(xml_detector)