|
1 | | -from asyncio import AbstractEventLoop |
2 | | -from threading import Event, Thread |
3 | | -from typing import Any, List, Optional, Union |
| 1 | +from asyncio import ( |
| 2 | + AbstractEventLoop, |
| 3 | + Event, |
| 4 | + Task, |
| 5 | +) |
| 6 | +from logging import Logger |
| 7 | +from typing import Any, Dict, List, Optional, Tuple |
4 | 8 |
|
| 9 | +from aiohttp import ClientWebSocketResponse |
| 10 | + |
| 11 | +from ..api.models.gw import Presence |
| 12 | +from ..base import get_logger |
| 13 | +from ..models.misc import MISSING |
5 | 14 | from .dispatch import Listener |
6 | 15 | from .http import HTTPClient |
7 | | -from .models.gw import Presence |
8 | 16 | from .models.flags import Intents |
9 | 17 |
|
10 | | -class Heartbeat(Thread): |
11 | | - ws: Any |
12 | | - interval: Union[int, float] |
| 18 | +log: Logger = get_logger("gateway") |
| 19 | + |
| 20 | +__all__ = ("_Heartbeat", "WebSocketClient") |
| 21 | + |
| 22 | +class _Heartbeat: |
13 | 23 | event: Event |
14 | | - def __init__(self, ws: Any, interval: int) -> None: ... |
15 | | - def run(self) -> None: ... |
16 | | - def stop(self) -> None: ... |
| 24 | + delay: float |
| 25 | + def __init__(self, loop: AbstractEventLoop) -> None: ... |
17 | 26 |
|
18 | | -class WebSocket: |
19 | | - intents: Intents |
20 | | - loop: AbstractEventLoop |
21 | | - dispatch: Listener |
22 | | - session: Any |
23 | | - session_id: Optional[int] |
24 | | - sequence: Optional[int] |
25 | | - keep_alive: Optional[Heartbeat] |
26 | | - closed: bool |
27 | | - http: Optional[HTTPClient] |
28 | | - options: dict |
| 27 | +class WebSocketClient: |
| 28 | + _loop: AbstractEventLoop |
| 29 | + _dispatch: Listener |
| 30 | + _http: HTTPClient |
| 31 | + _client: Optional[ClientWebSocketResponse] |
| 32 | + _closed: bool |
| 33 | + _options: dict |
| 34 | + _intents: Intents |
| 35 | + _ready: dict |
| 36 | + __heartbeater: _Heartbeat |
| 37 | + __shard: Optional[List[Tuple[int]]] |
| 38 | + __presence: Optional[Presence] |
| 39 | + __task: Optional[Task] |
| 40 | + session_id: int |
| 41 | + sequence: str |
29 | 42 | def __init__( |
30 | 43 | self, |
| 44 | + token: str, |
31 | 45 | intents: Intents, |
32 | | - session_id: Optional[int] = None, |
33 | | - sequence: Optional[int] = None, |
| 46 | + session_id: Optional[int] = MISSING, |
| 47 | + sequence: Optional[int] = MISSING, |
34 | 48 | ) -> None: ... |
35 | | - async def recv(self) -> Optional[Any]: ... |
36 | | - async def connect( |
37 | | - self, token: str, shard: Optional[List[int]] = None, presence: Optional[Presence] = None |
| 49 | + async def _manage_heartbeat(self) -> None: ... |
| 50 | + async def __restart(self): ... |
| 51 | + async def _establish_connection( |
| 52 | + self, shard: Optional[List[Tuple[int]]] = MISSING, presence: Optional[Presence] = MISSING |
38 | 53 | ) -> None: ... |
39 | | - async def handle_connection( |
40 | | - self, stream: dict, shard: Optional[List[int]] = None, presence: Optional[Presence] = None |
| 54 | + async def _handle_connection( |
| 55 | + self, |
| 56 | + stream: Dict[str, Any], |
| 57 | + shard: Optional[List[Tuple[int]]] = MISSING, |
| 58 | + presence: Optional[Presence] = MISSING, |
41 | 59 | ) -> None: ... |
42 | | - def handle_dispatch(self, event: str, data: dict) -> None: ... |
43 | | - def contextualize(self, data: dict) -> object: ... |
44 | | - async def send(self, data: Union[str, dict]) -> None: ... |
45 | | - async def identify( |
46 | | - self, shard: Optional[List[int]] = None, presence: Optional[Presence] = None |
| 60 | + @property |
| 61 | + async def __receive_packet_stream(self) -> Optional[Dict[str, Any]]: ... |
| 62 | + async def _send_packet(self, data: Dict[str, Any]) -> None: ... |
| 63 | + async def __identify( |
| 64 | + self, shard: Optional[List[Tuple[int]]] = None, presence: Optional[Presence] = None |
47 | 65 | ) -> None: ... |
48 | | - async def resume(self) -> None: ... |
49 | | - async def heartbeat(self) -> None: ... |
50 | | - def check_sub_auto(self, option) -> tuple: ... |
51 | | - def check_sub_command(self, option) -> dict: ... |
| 66 | + async def __resume(self) -> None: ... |
| 67 | + async def __heartbeat(self) -> None: ... |
| 68 | + @property |
| 69 | + def shard(self) -> None: ... |
| 70 | + @property |
| 71 | + def presence(self) -> None: ... |
0 commit comments