mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
24bc430290
commit
85545376ed
@ -176,6 +176,16 @@ static bool libhv_HttpServer_ws_set_ping_interval(int argc, py_Ref argv) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool libhv_HttpServer_ws_close(int argc, py_Ref argv) {
|
||||||
|
PY_CHECK_ARGC(2);
|
||||||
|
libhv_HttpServer* self = (libhv_HttpServer*)py_touserdata(py_arg(0));
|
||||||
|
PY_CHECK_ARG_TYPE(1, tp_int);
|
||||||
|
py_i64 channel = py_toint(py_arg(1));
|
||||||
|
int code = reinterpret_cast<hv::WebSocketChannel*>(channel)->close();
|
||||||
|
py_newint(py_retval(), code);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool libhv_HttpServer_ws_send(int argc, py_Ref argv) {
|
static bool libhv_HttpServer_ws_send(int argc, py_Ref argv) {
|
||||||
PY_CHECK_ARGC(3);
|
PY_CHECK_ARGC(3);
|
||||||
libhv_HttpServer* self = (libhv_HttpServer*)py_touserdata(py_arg(0));
|
libhv_HttpServer* self = (libhv_HttpServer*)py_touserdata(py_arg(0));
|
||||||
@ -245,6 +255,7 @@ py_Type libhv_register_HttpServer(py_GlobalRef mod) {
|
|||||||
py_bindmethod(type, "dispatch", libhv_HttpServer_dispatch);
|
py_bindmethod(type, "dispatch", libhv_HttpServer_dispatch);
|
||||||
|
|
||||||
py_bindmethod(type, "ws_set_ping_interval", libhv_HttpServer_ws_set_ping_interval);
|
py_bindmethod(type, "ws_set_ping_interval", libhv_HttpServer_ws_set_ping_interval);
|
||||||
|
py_bindmethod(type, "ws_close", libhv_HttpServer_ws_close);
|
||||||
py_bindmethod(type, "ws_send", libhv_HttpServer_ws_send);
|
py_bindmethod(type, "ws_send", libhv_HttpServer_ws_send);
|
||||||
py_bindmethod(type, "ws_recv", libhv_HttpServer_ws_recv);
|
py_bindmethod(type, "ws_recv", libhv_HttpServer_ws_recv);
|
||||||
return type;
|
return type;
|
||||||
|
@ -64,6 +64,9 @@ class HttpServer:
|
|||||||
def ws_set_ping_interval(self, milliseconds: int, /) -> None:
|
def ws_set_ping_interval(self, milliseconds: int, /) -> None:
|
||||||
"""Set WebSocket ping interval in milliseconds."""
|
"""Set WebSocket ping interval in milliseconds."""
|
||||||
|
|
||||||
|
def ws_close(self, channel: WsChannelId, /) -> ErrorCode:
|
||||||
|
"""Close WebSocket channel."""
|
||||||
|
|
||||||
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`."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user