示例#1
0
    def __init__(self, channel=channel):
        super(Client, self).__init__(channel=channel)
        self._response = None

        self._transport = TCPClient(channel=channel).register(self)

        HTTP(channel=channel).register(self._transport)
示例#2
0
 def request(self, event, method, url, body=None, headers={}, timeout=None):
     timeout = timeout or self._timeout
     if self._transport == None or not self._transport.connected:
         self._transport = TCPClient(channel=self.channel).register(self)
         HTTP(channel=self.channel).register(self._transport)
         self.fire(connect(self._host, self._port, self._secure),
                   self._transport)
         self._pending.append((method, url, body, headers, timeout))
     else:
         self._send_request(method, url, body, headers, timeout)
示例#3
0
    def __init__(self, url, channel=channel, wschannel="ws", headers=None):
        """
        :param url: the URL to connect to.
        :param channel: the channel used by this component
        :param wschannel: the channel used for the actual WebSocket
            communication (read, write, close events)
        :param headers: additional headers to be passed with the
            WebSocket setup HTTP request
        """
        super(WebSocketClient, self).__init__(channel=channel)

        self._url = url
        self._headers = headers or {}
        self._response = None
        self._pending = 0
        self._wschannel = wschannel

        self._transport = TCPClient(channel=self.channel).register(self)
        HTTP(channel=self.channel).register(self._transport)