Esempio n. 1
0
    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))
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
 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)
Esempio n. 5
0
File: ws.py Progetto: OpenSight/IVR
    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
Esempio n. 6
0
File: ws.py Progetto: dulton/IVR
    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
Esempio n. 7
0
 def __init__(self, addr, serdes):
     WebSocketClient.__init__(self, addr, protocols=['http-only', 'chat'])
     self.result = None
     self.disconnected = False
     self.serdes = serdes()
Esempio n. 8
0
 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