mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
Update libhv.pyi
This commit is contained in:
parent
1ff220b9dc
commit
24c0ed5138
@ -1,6 +1,5 @@
|
|||||||
from typing import Literal, Generator, Callable
|
from typing import Literal, Generator, Callable, Union
|
||||||
|
|
||||||
WsMessageType = Literal['onopen', 'onclose', 'onmessage']
|
|
||||||
WsChannelId = int
|
WsChannelId = int
|
||||||
HttpStatusCode = int
|
HttpStatusCode = int
|
||||||
HttpHeaders = dict[str, str]
|
HttpHeaders = dict[str, str]
|
||||||
@ -70,10 +69,12 @@ class HttpServer:
|
|||||||
def ws_send(self, channel: WsChannelId, data: str, /) -> int:
|
def ws_send(self, channel: WsChannelId, data: str, /) -> int:
|
||||||
"""Send WebSocket message through `channel`."""
|
"""Send WebSocket message through `channel`."""
|
||||||
|
|
||||||
def ws_recv(self) -> tuple[
|
def ws_recv(self) -> Union[
|
||||||
WsMessageType,
|
tuple[Literal['onopen'], tuple[WsChannelId, HttpRequest]],
|
||||||
tuple[WsChannelId, HttpRequest] | WsChannelId | tuple[WsChannelId, str]
|
tuple[Literal['onmessage'], tuple[WsChannelId, str]],
|
||||||
] | None:
|
tuple[Literal['onclose'], WsChannelId],
|
||||||
|
None
|
||||||
|
]:
|
||||||
"""Receive one WebSocket message.
|
"""Receive one WebSocket message.
|
||||||
Return one of the following or `None` if nothing to receive.
|
Return one of the following or `None` if nothing to receive.
|
||||||
|
|
||||||
@ -89,7 +90,12 @@ class WebSocketClient:
|
|||||||
def send(self, data: str, /) -> int:
|
def send(self, data: str, /) -> int:
|
||||||
"""Send WebSocket message."""
|
"""Send WebSocket message."""
|
||||||
|
|
||||||
def recv(self) -> tuple[WsMessageType, str | None] | None:
|
def recv(self) -> Union[
|
||||||
|
tuple[Literal['onopen'], None],
|
||||||
|
tuple[Literal['onclose'], None],
|
||||||
|
tuple[Literal['onmessage'], str],
|
||||||
|
None
|
||||||
|
]:
|
||||||
"""Receive one WebSocket message.
|
"""Receive one WebSocket message.
|
||||||
Return one of the following or `None` if nothing to receive.
|
Return one of the following or `None` if nothing to receive.
|
||||||
|
|
||||||
@ -101,3 +107,4 @@ class WebSocketClient:
|
|||||||
|
|
||||||
def strerror(errno: ErrorCode, /) -> str:
|
def strerror(errno: ErrorCode, /) -> str:
|
||||||
"""Get error message by errno via `hv_strerror`."""
|
"""Get error message by errno via `hv_strerror`."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user