From d83db77ce301c25bbfe02589e379acda74678090 Mon Sep 17 00:00:00 2001 From: Administrator <450292408@qq.com> Date: Tue, 14 Sep 2021 07:09:00 +0000 Subject: [PATCH] docs: update wg-basic/websocket --- wg-basic/websocket.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/wg-basic/websocket.md b/wg-basic/websocket.md index b1b9ff1..74fe23d 100644 --- a/wg-basic/websocket.md +++ b/wg-basic/websocket.md @@ -2,7 +2,7 @@ title: 即时消息 description: 即时消息模块的使用 published: true -date: 2021-09-14T06:44:48.671Z +date: 2021-09-14T07:08:58.741Z tags: wg-basic editor: markdown dateCreated: 2021-09-14T06:25:26.887Z @@ -40,4 +40,32 @@ websocket: 3. 请求接口后,拿到会话ID(sessionId) 4. 初始化 WebSocket -5. 连接打开后,发起 **会话注册**,携带请求后的 sessionId \ No newline at end of file +5. 连接打开后,发起 **会话注册**,携带请求后的 **sessionId** 完成会话注册。 +6. 注册成功后,可发起 scoket 请求 + +# 类型与参数 +## 1. 消息格式说明 + +消息格式为 **JSONObject** 字符串 +具体内容如下表 + +| 名称 | 说明 | +| :-: | :-: | +| type | 消息类型编码 | +| isSystem | 是否是系统消息 | +| from | 发送人的 **userId** | +| to | 接收人的 **userId** 或 **userId 列表**。userId 列表为 **英文逗号** 分割的字符串 | +| body | 消息主体,主体的具体格式会根据 **消息编码(type)** 的变化而变化 + +## 2. 请求类型编码 + +| 编码 | 说明 | 主体格式 | +| :-: | :-: | :-: | +| 1000 | 注册消息 | RegisterBody 的 JSONObject 字符串 | +| 2001 | 文本消息 | 发送的字符串内容 | +| 9001 | 消息发送状态 | StatusBody 的 JSONObject 字符串 | +| 9101 | 消息接受状态 | StatusBody 的 JSONObject 字符串 | + +## 3. 响应类型 + +## 4. 主体