docs: update wg-basic/websocket

This commit is contained in:
Administrator 2021-09-14 07:09:00 +00:00 committed by John Smith
parent bd305f7708
commit d83db77ce3

View File

@ -2,7 +2,7 @@
title: 即时消息 title: 即时消息
description: 即时消息模块的使用 description: 即时消息模块的使用
published: true published: true
date: 2021-09-14T06:44:48.671Z date: 2021-09-14T07:08:58.741Z
tags: wg-basic tags: wg-basic
editor: markdown editor: markdown
dateCreated: 2021-09-14T06:25:26.887Z dateCreated: 2021-09-14T06:25:26.887Z
@ -40,4 +40,32 @@ websocket:
3. 请求接口后拿到会话IDsessionId 3. 请求接口后拿到会话IDsessionId
4. 初始化 WebSocket 4. 初始化 WebSocket
5. 连接打开后,发起 **会话注册**,携带请求后的 sessionId 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. 主体