class Emitter: def __init__(self, cs): o = urlparse(cs) if o.scheme == 'udp': self.sub = UDPEmitter(o.hostname, o.port) # TODO: http, websocket # Very simple interface, def send(self, obj): obj['time'] = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") return self.sub.send(json.dumps(obj)) def close(self): return self.sub.close()
def __init__(self, cs): o = urlparse(cs) if o.scheme == 'udp': self.sub = UDPEmitter(o.hostname, o.port) if o.scheme == 'ws': self.sub = WSEmitter(o.hostname, o.port, o.path)
def __init__(self, cs): o = urlparse(cs) if o.scheme == 'udp': self.sub = UDPEmitter(o.hostname, o.port)