def __init__(self, url, recv_msg_cbk=None, close_cbk=None, protocols=None, msg_encoder=None, msg_decoder=None): # patch socket.sendall to protect it with lock, # in order to prevent sending data from multiple greenlets concurrently WebSocketClient.__init__(self, url, protocols=protocols) self._msg_encoder = msg_encoder or self.DEFAULT_ENCODER self._msg_decoder = msg_decoder or self.DEFAULT_DECODER lock = RLock() _sendall = self.sock.sendall self._recv_msg_cbk = recv_msg_cbk self._close_cbk = close_cbk def sendall(data): lock.acquire() try: _sendall(data) except Exception: raise finally: lock.release() self.sock.sendall = sendall self.connect() log.info('Created {0}'.format(self))
def __init__(self, host, port, path, opts): url = "ws://{0}:{1}{2}".format(host, port, path) WebSocketClient.__init__(self, url) self.path = path self.shutdown_cond = Event() self.opts = opts self.iohelper = common.StdioPipedWebSocketHelper(self.shutdown_cond, opts)
def __init__(self, scheme, host, port, path, opts): url = "{0}://{1}:{2}{3}".format(scheme, host, port, path) WebSocketClient.__init__(self, url) self.path = path self.shutdown_cond = Event() self.opts = opts self.iohelper = common.StdioPipedWebSocketHelper(self.shutdown_cond, opts)
def __init__(self, server=None, origin=None, token=None): self._token = token self._ids = itertools.count(0) self._results = {} self._streams = {} headers = [] if origin is not None: headers.append((u"Origin", unicode(origin))) WebSocketClient.__init__(self, server, protocols=["http-only"], headers=headers)
def __init__(self, url): self._close_event = Event() # patch socket.sendall to protect it with lock, # in order to prevent sending data from multiple greenlets concurrently WebSocketClient.__init__(self, url) self._app = None self._lock = RLock() _sendall = self.sock.sendall def sendall(data): self._lock.acquire() try: _sendall(data) except: raise finally: self._lock.release() self.sock.sendall = sendall
def __init__(self, addr, serdes): WebSocketClient.__init__(self, addr, protocols=['http-only', 'chat']) self.result = None self.disconnected = False self.serdes = serdes()
def __init__(self, url, event_listeners, protocols=None, extensions=None, ssl_options=None, headers=None): WebSocketClient.__init__(self, url, protocols, extensions, ssl_options=ssl_options, headers=headers) self.listeners = event_listeners