bricks/examples/echo.ws
2024-04-28 11:18:17 +08:00

16 lines
536 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ws_data 客户端传过来的数据
# ws_pool 保存所有链接
# register(id)
# 注册自己id必须唯一
# sendto(data, id=None)
# 发送消息给客户端当id为空时发送给当前链接的客户端否则发送给id指定的客户端
# is_online(id)
# 检查id指定的客户端是否在线
# user = await get_user()
# ws_pool.register(user)
resp = 'resp=' + ws_data
print(f'{resp=}')
await ws_pool.sendto(resp)
# if ws_pool.is_online('bington'):
# await ws_pool.sendto(resp, 'bington')