-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathuwebsocket.pyi
More file actions
63 lines (44 loc) · 1.69 KB
/
Copy pathuwebsocket.pyi
File metadata and controls
63 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Function:
This feature establishes a WebSocket connection.
Descriptions taken from:
https://python.quectel.com/doc/quecpython/API_reference/en/networklib/uwebsocket.html
"""
CLOSE_OK: int = 1000
class Websocket(object):
"""
Basis of the Websocket protocol.
This can probably be replaced with the C-based websocket module, but
this one currently supports more options.
"""
is_client = False
def recv(self):
"""Receive data from the websocket.
This is slightly different from 'websockets' in that it doesn't
fire off a routine to process frames and put the data in a queue.
If you don't call recv() sufficiently often you won't process control
frames.
:return: String type. The returned result. When this value is null or None, the connection is closed.
"""
def send(self, buf):
"""Send data to the websocket.
:param buf:
:return:
"""
def close(self, code=CLOSE_OK, reason=''):
"""Close the websocket.
:param code:
:param reason:
:return:
"""
class WebsocketClient(Websocket):
is_client = True
class Client(object):
@classmethod
def connect(cls, url, headers=None, debug=False) -> WebsocketClient:
"""
:param url:String type. WebSocket connection URL, usually in the form of "ws://xxx/" or "wss://xxx/".
:param headers:Dict type. The additional header to be added, used in the scenarios where both the standard header and the additional header passed by users are allowed.
:param debug:Bool type. True – Output logs. False – Not output logs. Default value: False.
:return:
"""