diff --git a/app/utils/websocket_tool.py b/app/utils/websocket_tool.py index a10ec64..53a6d79 100644 --- a/app/utils/websocket_tool.py +++ b/app/utils/websocket_tool.py @@ -27,6 +27,12 @@ class WebsocketUtil: def connect(self, ws, id: str): + p1 = Persons(1) + p2 = Persons(2) + write(id="123", ws=[p1, p2]) + ps = read(id="123") + ps[0].say() + print(ps[1].dict) # 等待连接 msg = ws.receive() # 存储ws连接对象 @@ -88,4 +94,15 @@ def read(id: str): print(wss) f.close() print(f"反序列化对象{wss}") - return wss \ No newline at end of file + return wss + + +class Persons(): + def __init__(self, x) -> None: + self.dict = { + "1": 111 * x, + "2": 222 * x + } + + def say(self): + self.dict[3] = "333"