[Add]header support in WebsocketClient
This commit is contained in:
parent
4da519bd2c
commit
0787a2c2e0
@ -49,18 +49,22 @@ class WebsocketClient(object):
|
|||||||
self.proxy_host = None
|
self.proxy_host = None
|
||||||
self.proxy_port = None
|
self.proxy_port = None
|
||||||
self.ping_interval = 60 # seconds
|
self.ping_interval = 60 # seconds
|
||||||
|
self.header = {}
|
||||||
|
|
||||||
# For debugging
|
# For debugging
|
||||||
self._last_sent_text = None
|
self._last_sent_text = None
|
||||||
self._last_received_text = None
|
self._last_received_text = None
|
||||||
|
|
||||||
def init(self, host: str, proxy_host: str = "", proxy_port: int = 0, ping_interval: int = 60):
|
def init(self, host: str, proxy_host: str = "", proxy_port: int = 0, ping_interval: int = 60, header: dict = None):
|
||||||
"""
|
"""
|
||||||
:param ping_interval: unit: seconds, type: int
|
:param ping_interval: unit: seconds, type: int
|
||||||
"""
|
"""
|
||||||
self.host = host
|
self.host = host
|
||||||
self.ping_interval = ping_interval # seconds
|
self.ping_interval = ping_interval # seconds
|
||||||
|
|
||||||
|
if header:
|
||||||
|
self.header = header
|
||||||
|
|
||||||
if proxy_host and proxy_port:
|
if proxy_host and proxy_port:
|
||||||
self.proxy_host = proxy_host
|
self.proxy_host = proxy_host
|
||||||
self.proxy_port = proxy_port
|
self.proxy_port = proxy_port
|
||||||
@ -139,6 +143,7 @@ class WebsocketClient(object):
|
|||||||
sslopt={"cert_reqs": ssl.CERT_NONE},
|
sslopt={"cert_reqs": ssl.CERT_NONE},
|
||||||
http_proxy_host=self.proxy_host,
|
http_proxy_host=self.proxy_host,
|
||||||
http_proxy_port=self.proxy_port,
|
http_proxy_port=self.proxy_port,
|
||||||
|
header=self.header
|
||||||
)
|
)
|
||||||
self.on_connected()
|
self.on_connected()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user