Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
c00e1b05
Commit
c00e1b05
authored
Oct 11, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改文档
parent
3459d0aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
153 additions
and
54 deletions
+153
-54
config/src/main/resources/static/Wecloud-IM-Websocket-Docs.html
+0
-0
docs/md/wecloud-im前端Websocket对接文档.md
+25
-13
docs/md/wecloud-im单人RTC对接文档的.md
+128
-41
No files found.
config/src/main/resources/static/Wecloud-IM-Websocket-Docs.html
View file @
c00e1b05
This source diff could not be displayed because it is too large. You can
view the blob
instead.
docs/md/wecloud-im前端Websocket对接文档.md
View file @
c00e1b05
# wec
loud-im 前端Websocket对接文档
# wec
loud-im 前端Websocket对接文档
...
@@ -65,38 +65,51 @@ clientId:由后端生成
...
@@ -65,38 +65,51 @@ clientId:由后端生成
**已读**
为客户端已经查看该消息
**已读**
为客户端已经查看该消息
## ping / pong心跳机制
1.
客户端接收到服务端下发"ping"字符串时, 必须立即回应"pong"字符串;
2.
客户端可完善定时向服务端发起"ping"字符串,来保持websocket连接状态, 服务端会立即回应"pong"字符串,如果连续3次未及时响应"pong",即可认定websocket已经断开,进入重新连接流程;
3.
建议客户端发"ping"间隔时间为5秒
## 客户端登陆
## 客户端登陆


1.
appKey, appSecret为蔚可云下发给客户方安全保护密钥,不建议保存在前端客户端;
1.
appKey, appSecret为蔚可云下发给客户方安全保护密钥,不建议保存在前端客户端;
2.
第三方应用服务端需提供获取sign的接口, sign 由MD5{timestamp + clientId + appKey + appSecret},其中clientId由后端生成;
2.
第三方应用服务端需提供获取sign的接口, sign 由MD5{timestamp + clientId + appKey + appSecret},其中clientId由后端生成;
3.
前端拿到sign后,调用验证sign接口进行获取token;
3.
前端拿到sign后,调用验证sign接口进行获取token;
4.
websocket连接初始化需要带上token即可连接成功;
4.
websocket连接初始化需要带上token即可连接成功;
5.
sign 需要在你的应用服务端生成;
### 第三方应用后端生成sign接口示例
### 第三方应用后端生成sign接口示例
本文展示如何在服务端部署一个 sign 生成器。
**java**
示例代码 ,供客户应用后端参考
**java**
示例代码 ,供客户应用后端参考
```
java
```
java
private
void
getSign
(
String
timestemp
,
String
clientId
,
String
appKey
,
String
appSecret
)
{
import
org.springframework.util.DigestUtils
;
String
sign
=
new
MD5
().
digestHex
(
timestemp
+
clientId
+
appKey
+
appSecret
);
private
void
getSign
(
String
timestamp
,
String
clientId
,
String
appKey
,
String
appSecret
)
{
String
data
=
timestamp
+
clientId
+
appKey
+
appSecret
;
String
sign
=
DigestUtils
.
md5DigestAsHex
(
data
.
getBytes
());
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
clientId
=
"client_123123"
;
String
clientId
=
"client_123123"
;
String
appKey
=
"elLwpel1gWCHDqZy"
;
String
appKey
=
"elLwpel1gWCHDqZy"
;
String
appSecret
=
"68809bb5a9077a83631aeb0b17b5965d6b2302faf2ab3737"
;
String
appSecret
=
"68809bb5a9077a83631aeb0b17b5965d6b2302faf2ab3737"
;
String
timest
e
mp
=
String
.
valueOf
(
new
Date
().
getTime
());
String
timest
a
mp
=
String
.
valueOf
(
new
Date
().
getTime
());
getSign
(
timest
e
mp
,
clientId
,
appKey
,
appSecret
);
getSign
(
timest
a
mp
,
clientId
,
appKey
,
appSecret
);
}
}
```
```
后端必须需要响应
参数:
第三方应用后端需要响应的
参数:
```
```
json
{
{
"timestamp"
:
"1628838135066"
,
"timestamp"
:
"1628838135066"
,
"clientId"
:
"client_3334444"
,
"clientId"
:
"client_3334444"
,
...
@@ -111,7 +124,7 @@ ws://localhost:8899/ws?token=xxxxxx&platform=1
...
@@ -111,7 +124,7 @@ ws://localhost:8899/ws?token=xxxxxx&platform=1
示例:
示例:
```
```
text
ws://localhost:8899/ws?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWIiLCJjbGllbnRJZCI6ImhhaGFoXzMwIiwiaXNzIjoid2VjbG91ZF9pbSIsImFwcEtleSI6ImVsTHdwZWwxZ1dDSERxWnkiLCJleHAiOjE2MjkwOTY0MzksImlhdCI6MTYyMDQ1NjQzOSwianRpIjoiNDA1YzE3MWM2Njc5NGJmMDllNGRjZDdhNzA0ZjY3YTgifQ.7g2J_0q9UnuWszpuapSJUXJEwVevvI8Rm2Srg3594Lk&platform=1
ws://localhost:8899/ws?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWIiLCJjbGllbnRJZCI6ImhhaGFoXzMwIiwiaXNzIjoid2VjbG91ZF9pbSIsImFwcEtleSI6ImVsTHdwZWwxZ1dDSERxWnkiLCJleHAiOjE2MjkwOTY0MzksImlhdCI6MTYyMDQ1NjQzOSwianRpIjoiNDA1YzE3MWM2Njc5NGJmMDllNGRjZDdhNzA0ZjY3YTgifQ.7g2J_0q9UnuWszpuapSJUXJEwVevvI8Rm2Srg3594Lk&platform=1
```
```
...
@@ -155,7 +168,6 @@ wss://ws.im199.com/ws?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWI
...
@@ -155,7 +168,6 @@ wss://ws.im199.com/ws?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ3ZWI
## 请求CMD指令说明
## 请求CMD指令说明
-
1: 发送IM消息请求
-
1: 发送IM消息请求
-
3: 单人WebRTC请求
-
3: 单人WebRTC请求
## 响应CMD指令说明
## 响应CMD指令说明
...
@@ -237,7 +249,7 @@ websocket是异步的 有可能你很快速的发送了几条消息,服务器响
...
@@ -237,7 +249,7 @@ websocket是异步的 有可能你很快速的发送了几条消息,服务器响
**示例一: 必传参数:**
**示例一: 必传参数:**
```
```
json
{
{
"reqId"
:
"123123123"
,
"reqId"
:
"123123123"
,
"cmd"
:
1
,
"cmd"
:
1
,
...
...
docs/md/wecloud-im单人RTC对接文档的.md
View file @
c00e1b05
# wecloud-RTC音视频客户端对接文档
# wecloud-RTC音视频客户端信令对接文档
# wecloud-RTC音视频客户端对接文档
# wecloud-RTC音视频客户端信令对接文档
## 文档描述
## 文档描述
...
@@ -27,17 +27,21 @@ client需要监听频道内 状态更新(房间断开,挂断)、用户状态更
...
@@ -27,17 +27,21 @@ client需要监听频道内 状态更新(房间断开,挂断)、用户状态更
## 指令说明
## 指令说明
**subCmd**
子类型
#### **subCmd**子类型
##### 客户端**请求**指令列表:
客户端
**请求**
指令列表:
**create**
:创建频道
**create**
:创建频道
**join**
: 加入频道
**join**
: 加入频道
服务端
**响应**
指令列表:
##### 服务端**响应**指令列表:
**rtcCall**
:接收到RTC邀请
**rtcCall**
:接收到RTC邀请
**
userEvent**
: 用户状态更新事件(用户加入, 用户退出
)
**
clientEvent**
: 用户状态更新事件(用户加入,用户退出,用户拒接邀请
)
**type
Change
Event**
:流状态更新(切换音频 切换视频)
**typeEvent**
:流状态更新(切换音频 切换视频)
**statusEvent**
:状态更新(网络断开,挂断)
**statusEvent**
:状态更新(网络断开,挂断)
**SDP**
:SDP数据转发
**busy**
:忙线
## 创建频道 发起RTC音视频通话
## 创建频道 发起RTC音视频通话
...
@@ -126,14 +130,16 @@ client需要监听频道内 状态更新(房间断开,挂断)、用户状态更
...
@@ -126,14 +130,16 @@ client需要监听频道内 状态更新(房间断开,挂断)、用户状态更
```
json
```
json
{
{
"reqId"
:
""
,
"cmd"
:
4
,
"cmd"
:
4
,
"data"
:{
"data"
:{
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"toConversation"
:
null
,
"channelId"
:
1234263457652
,
"subCmd"
:
"rtcCall"
,
"subCmd"
:
"rtcCall"
,
"sender"
:
"client_1010"
,
"subData"
:{
"type"
:
"video"
,
"toConversation"
:
null
,
"channelId"
:
1234263457652
,
"sender"
:
"client_1010"
},
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"attrs"
:{
"attrs"
:{
"a"
:
"示例: 用户自定义的一些键值对"
,
"a"
:
"示例: 用户自定义的一些键值对"
,
"b"
:
"存储用户自定义的一些键值对"
"b"
:
"存储用户自定义的一些键值对"
...
@@ -153,11 +159,11 @@ client需要监听频道内 状态更新(房间断开,挂断)、用户状态更
...
@@ -153,11 +159,11 @@ client需要监听频道内 状态更新(房间断开,挂断)、用户状态更
| subCmd | String | 否 | 子类型指令 |
| subCmd | String | 否 | 子类型指令 |
| sender | String | 否 | 发起通话的客户端ID |
| sender | String | 否 | 发起通话的客户端ID |
| channelId | Long | 否 | 由服务端创建的频道id |
| channelId | Long | 否 | 由服务端创建的频道id |
| type | String | 否 | 类型: "video" 或 "voice" |
## 同意加入频道
## 接收方同意加入频道
client接收方向服务端请求数据:
client接收方向服务端发送数据:
```
json
```
json
{
{
...
@@ -179,34 +185,35 @@ client接收方向服务端发送数据:
...
@@ -179,34 +185,35 @@ client接收方向服务端发送数据:
| diyParam自定义字段 | Object | 是 | 自定义拓展字段 |
| diyParam自定义字段 | Object | 是 | 自定义拓展字段 |
| subCmd | String | 否 | 子类型指令 |
| subCmd | String | 否 | 子类型指令 |
##
# 通知发起方: 接收方同意
加入频道
##
通知:有client
加入频道
服务端向
发送方下发
数据:
服务端向
频道内其他client响应
数据:
```
json
```
json
{
{
"reqId"
:
"123"
,
"cmd"
:
4
,
"cmd"
:
4
,
"data"
:{
"data"
:{
"channelId"
:
1234263457652
,
"subCmd"
:
"clientEvent"
,
"clientId"
:
"adsfadf"
,
"subData"
:{
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"channelId"
:
1234263457652
,
"subCmd"
:
"agree"
"type"
:
"join"
,
"clientId"
:
7657567
,
}
}
}
}
}
```
```
##
接收方
拒绝加入频道
## 拒绝加入频道
client接收方向服务端
发送
数据:
client接收方向服务端
请求
数据:
```
json
```
json
{
{
"reqId"
:
"123"
,
"reqId"
:
"123"
,
"cmd"
:
3
,
"cmd"
:
3
,
"data"
:{
"data"
:{
"subCmd"
:
"reject"
,
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"channelId"
:
1234263457652
,
"channelId"
:
1234263457652
,
"subCmd"
:
"reject"
,
"attrs"
:{}
"attrs"
:{}
}
}
}
}
...
@@ -224,43 +231,123 @@ client接收方向服务端发送数据:
...
@@ -224,43 +231,123 @@ client接收方向服务端发送数据:
| diyParam自定义字段 | Object | 是 | 自定义拓展字段 |
| diyParam自定义字段 | Object | 是 | 自定义拓展字段 |
| subCmd | String | 否 | 子类型 |
| subCmd | String | 否 | 子类型 |
##
# 通知发送方: 接收方
拒绝加入频道
##
通知:有Client
拒绝加入频道
服务端向
发送方下发
数据:
服务端向
频道内其他client响应
数据:
```
json
```
json
{
{
"reqId"
:
"123"
,
"cmd"
:
4
,
"cmd"
:
4
,
"data"
:{
"data"
:{
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"subCmd"
:
"clientEvent"
,
"toConversation"
:
1402147846261706752
,
"subData"
:{
"subCmd"
:
"reject"
"channelId"
:
1234263457652
,
"type"
:
"reject"
,
"clientId"
:
7657567
,
}
}
}
}
}
```
```
## 流媒体描述信息SDP转发
## 流媒体描述信息SDP转发
(服务端仅负责转发)(ice_candidate,anser,offer)
(服务端仅负责转发)(ice_candidate,anser,offer)
##
视频/音频切换
##
# client发送SDP
## 有用户离开频道
```
json
{
"reqId"
:
"123"
,
"cmd"
:
3
,
"data"
:{
"subCmd"
:
"sdp"
,
"channelId"
:
1234263457652
,
"sdpData"
:
"xxxxxxxxxxxxxxxx"
,
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"attrs"
:{}
}
}
```
## 系统电话繁忙
##
断线重连
##
# client接收SDP
## 发送心跳
```
json
{
"cmd"
:
4
,
"data"
:{
"subCmd"
:
"sdp"
,
"subData"
:{
"channelId"
:
1234263457652
,
"clientId"
:
7657567
,
"sdpData"
:
"xxxxxxxxxxxxxxxx"
,
"diyParam自定义字段"
:
"aaaa自已定义字段的值"
,
"attrs"
:{}
}
}
}
```
## 对方是否还挂起
## 主动挂断(离开频道)
client主动离开频道
向服务端请求:
```
json
{
"reqId"
:
"123"
,
"cmd"
:
3
,
"data"
:{
"subCmd"
:
"leave"
,
"channelId"
:
1234263457652
}
}
```
## 通知:有client离开频道
服务端向频道内其他client响应数据:
```
json
{
"cmd"
:
4
,
"data"
:{
"subCmd"
:
"clientEvent"
,
"subData"
:{
"channelId"
:
1234263457652
,
"type"
:
"leave"
,
"clientId"
:
7657567
,
}
}
}
```
## 对方忙线(对方正在通话中)
服务端响应给发起方
```
json
{
"reqId"
:
"555111-ad-afd12"
,
"cmd"
:
5
,
"data"
:{
"subCmd"
:
"busy"
,
"subData"
:{
"channelId"
:
1234263457652
,
"clientId"
:
7657567
}
}
}
```
##
挂断
##
断线重连
## 确认离开
重新join进频道即可重连
## 确认是否离开
## 对方是否还挂起
## 视频/音频切换
## 查询对方是否离开
## 查询对方是否离开
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment