def __init__(self, server_url): """Creates a new 'SynchronousEventPublisher' object. Events are sent in separate HTTP requests to the server given by 'server_url'. """ scheme, self.hostname, self.port, self.path = split_url(server_url) assert scheme == 'http' if not self.path.endswith('/publish'): if self.path.endswith('/'): self.path = self.path + 'publish' else: self.path = self.path + '/publish'
def _create_publisher(url, publisher_type='ztreamy'): """Creates a publisher object for the given server URL. If the URL is '-', events are written to stdout. """ ioloop = tornado.ioloop.IOLoop.instance() if url == '-': return utils.StdoutPublisher(ioloop=ioloop) elif publisher_type == 'ztreamy': return client.EventPublisher(url, io_loop=ioloop) elif publisher_type == 'bayeux': # Use the path as channel name scheme, server, port, path = split_url(url) assert scheme == 'http' server_url = '{0}://{1}:{2}/'.format(scheme, server, port) return BayeuxEventPublisher(server_url, path, io_loop=ioloop)
def __init__(self, server_url, serialization_type=ztreamy.SERIALIZATION_ZTREAMY): """Creates a new 'SynchronousEventPublisher' object. Events are sent in separate HTTP requests to the server given by 'server_url'. """ scheme, self.hostname, self.port, self.path = split_url(server_url) assert scheme == 'http' if not self.path.endswith('/publish'): if self.path.endswith('/'): self.path = self.path + 'publish' else: self.path = self.path + '/publish' self.serialization_type = serialization_type self.headers = dict(SynchronousEventPublisher._headers) if serialization_type == ztreamy.SERIALIZATION_JSON: self.headers['Content-Type'] = ztreamy.json_media_type