网状网络管理 (Mesh)

本文讲述网状网络(Mesh)相关的接口。网状网络是一种分布式架构,允许多个独立域之间进行通信和数据同步。我们提供有Java版本的SDK,建议使用Java语言的客户使用这个SDK,其它语言可以按照本文档对接。

1. 域名管理

1.1. 创建域名

创建一个新的网状网络域。

1.1.1. 地址

http://domain:18080/admin/domain/create

1.1.2. body

参数 类型 必需 描述
domainId string 否 域名ID,如果传空,系统会自动生成
name string 是 域名名称
desc string 否 域名描述
extra string 否 附加信息

1.1.3. 响应

N/A

1.1.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"name\":\"domain1\"}" http://localhost:18080/admin/domain/create

{
  "code":0,
  "msg":"success"
}

1.2. 获取域名信息

获取指定域名的详细信息。

1.2.1. 地址

http://domain:18080/admin/domain/get

1.2.2. body

参数 类型 必需 描述
value string 是 域名ID

1.2.3. 响应

参数 类型 必需 描述
domainId string 是 域名ID
name string 是 域名名称
desc string 否 域名描述
extra string 否 附加信息

1.2.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"value\":\"domain1\"}" http://localhost:18080/admin/domain/get

{
  "code":0,
  "msg":"success",
  "result":{
    "domainId":"domain1",
    "name":"Domain 1"
  }
}

1.3. 删除域名

删除指定的网状网络域。

1.3.1. 地址

http://domain:18080/admin/domain/destroy

1.3.2. body

参数 类型 必需 描述
value string 是 域名ID

1.3.3. 响应

N/A

1.3.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"value\":\"domain1\"}" http://localhost:18080/admin/domain/destroy

{
  "code":0,
  "msg":"success"
}

1.4. 获取所有域名

获取系统中所有的域名列表。

1.4.1. 地址

http://domain:18080/admin/domain/list

1.4.2. body

N/A

1.4.3. 响应

参数 类型 必需 描述
result Object[] 是 域名信息列表

1.4.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" http://localhost:18080/admin/domain/list

{
  "code":0,
  "msg":"success",
  "result":[
    {
      "domainId":"domain1",
      "name":"Domain 1"
    }
  ]
}

1.5. Ping域名

检查指定域名的连通状态。

1.5.1. 地址

http://domain:18080/admin/domain/ping

1.5.2. body

参数 类型 必需 描述
domainId string 是 域名ID

1.5.3. 响应

参数 类型 必需 描述
status string 是 域名状态

1.5.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"domainId\":\"domain1\"}" http://localhost:18080/admin/domain/ping

{
  "code":0,
  "msg":"success",
  "result":{
    "status":"online"
  }
}

2. 用户管理

2.1. 批量获取用户信息

根据用户ID列表批量获取用户信息。

2.1.1. 地址

http://domain:18080/admin/user/batch_get_infos

2.1.2. body

参数 类型 必需 描述
list string[] 是 用户ID列表

2.1.3. 响应

参数 类型 必需 描述
result Object[] 是 用户信息列表

2.1.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"list\":[\"user1\",\"user2\"]}" http://localhost:18080/admin/user/batch_get_infos

{
  "code":0,
  "msg":"success",
  "result":[...]
}

2.2. 搜索用户

根据关键词搜索用户。

2.2.1. 地址

http://domain:18080/admin/user/search_user

2.2.2. body

参数 类型 必需 描述
keyword string 是 搜索关键词
searchType int 是 搜索类型
userType int 是 用户类型
page int 是 页码

2.2.3. 响应

参数 类型 必需 描述
result Object[] 是 搜索结果列表

2.2.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"keyword\":\"test\",\"searchType\":0,\"userType\":0,\"page\":0}" http://localhost:18080/admin/user/search_user

{
  "code":0,
  "msg":"success",
  "result":[...]
}

3. 关系管理

3.1. 发送好友请求

向指定用户发送好友请求。

3.1.1. 地址

http://domain:18080/admin/friend/send_request

3.1.2. body

参数 类型 必需 描述
userId string 是 发送者用户ID
friendUid string 是 目标用户ID
reason string 否 申请理由
force bool 否 是否强制添加

3.1.3. 响应

N/A

3.1.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"user1\",\"friendUid\":\"user2\",\"reason\":\"加个好友\"}" http://localhost:18080/admin/friend/send_request

{
  "code":0,
  "msg":"success"
}

3.2. 处理好友请求

接受或拒绝好友请求。

3.2.1. 地址

http://domain:18080/admin/friend/handle_send_request

3.2.2. body

参数 类型 必需 描述
userId string 是 用户ID
friendUid string 是 好友用户ID
status int 是 处理状态,0拒绝,1接受

3.2.3. 响应

N/A

3.2.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d "{\"userId\":\"user1\",\"friendUid\":\"user2\",\"status\":1}" http://localhost:18080/admin/friend/handle_send_request

{
  "code":0,
  "msg":"success"
}

4. 消息管理

4.1. 发送消息

在网状网络中发送消息。

4.1.1. 地址

http://domain:18080/admin/message/send

此接口复用普通消息发送接口,需要设置 meshMessage=true

4.1.2. body

参数 类型 必需 描述
sender string 是 发送者ID
conv json 是 会话
payload json 是 消息负载
toUsers string[] 否 指定接收用户
meshMessage bool 是 设置为true表示网状消息

4.1.3. 响应

参数 类型 必需 描述
messageUid long 是 消息唯一ID
timestamp long 是 服务器处理时间

4.1.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d   \
  "{                       \
    \"sender\":\"user1\",       \
    \"conv\": {              \
      \"type\":1,            \
      \"target\":\"user2\",      \
      \"line\":0           \
    },                        \
    \"payload\":{                 \
      \"type\":1,                       \
      \"searchableContent\":\"hello\"   \
    },                                   \
    \"meshMessage\":true                        \
  }"                                \
  http://localhost:18080/admin/message/send

{
  "code":0,
  "msg":"success",
  "result":{
    "messageUid":5323423532,
    "timestamp":13123423234324
  }
}

4.2. 发布消息

向指定接收者发布消息。

4.2.1. 地址

http://domain:18080/admin/message/publish

4.2.2. body

参数 类型 必需 描述
messageData Object 是 消息数据
receivers string[] 是 接收者ID列表
messageId long 是 消息ID

4.2.3. 响应

参数 类型 必需 描述
messageUid long 是 消息唯一ID
timestamp long 是 服务器处理时间

4.2.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d   \
  "{                       \
    \"messageData\":{...},                        \
    \"receivers\":[\"user1\",\"user2\"],                        \
    \"messageId\":123456                        \
  }"                                \
  http://localhost:18080/admin/message/publish

{
  "code":0,
  "msg":"success",
  "result":{
    "messageUid":5323423532,
    "timestamp":13123423234324
  }
}

5. 群组管理

5.1. 同步群组

将群组信息同步到网状网络。

5.1.1. 地址

http://domain:18080/admin/mesh/group_sync

5.1.2. body

参数 类型 必需 描述
group_info json 是 群组信息
members Object[] 是 群成员列表

5.1.3. 响应

N/A

5.1.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d   \
  "{                       \
    \"group_info\":{...},                        \
    \"members\":[...]                        \
  }"                                \
  http://localhost:18080/admin/mesh/group_sync

{
  "code":0,
  "msg":"success"
}

以下群组接口复用普通群组API,需要设置 meshMessage=true:

  • 获取群组信息: /admin/group/get_info
  • 获取群组成员: /admin/group/member/list
  • 添加群成员: /admin/group/member/add
  • 批量获取群组: /admin/group/batch_infos
  • 退出群组: /admin/group/member/quit
  • 解散群组: /admin/group/del
  • 踢出群成员: /admin/group/member/del
  • 转让群组: /admin/group/transfer
  • 修改群组信息: /admin/group/modify

6. 会议管理

6.1. 用户会议请求

处理用户的会议请求。

6.1.1. 地址

http://domain:18080/admin/conference/user_request

6.1.2. body

参数 类型 必需 描述
clientID string 是 客户端ID
fromUser string 是 发起用户ID
request string 是 请求内容
sessionId long 是 会话ID
roomId string 是 房间ID
data string 否 附加数据
advanced bool 否 是否高级会议

6.1.3. 响应

参数 类型 必需 描述
result Object 是 响应结果

6.1.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d   \
  "{                       \
    \"clientID\":\"client1\",       \
    \"fromUser\":\"user1\",                        \
    \"request\":\"join\",                        \
    \"sessionId\":123456,                        \
    \"roomId\":\"room1\",                        \
    \"advanced\":false                        \
  }"                                \
  http://localhost:18080/admin/conference/user_request

{
  "code":0,
  "msg":"success",
  "result":{...}
}

6.2. 用户会议事件

处理用户的会议事件。

6.2.1. 地址

http://domain:18080/admin/conference/user_event

6.2.2. body

参数 类型 必需 描述
data string 是 事件数据
userId string 是 用户ID
clientId string 是 客户端ID
isRobot bool 否 是否机器人

6.2.3. 响应

N/A

6.2.4. 示例

curl -X POST -H "nonce:76616" -H "timestamp":"1558350862502" -H "sign":"b98f9b0717f59febccf1440067a7f50d9b31bdde" -H "Content-Type:application/json" -d   \
  "{                       \
    \"data\":\"event_data\",                        \
    \"userId\":\"user1\",                        \
    \"clientId\":\"client1\",                        \
    \"isRobot\":false                        \
  }"                                \
  http://localhost:18080/admin/conference/user_event

{
  "code":0,
  "msg":"success"
}
2018 © wildfirechat.net 京ICP备18060403号-1 all right reserved,powered by Gitbook该文件修订时间: 2026-01-30 17:10:18

results matching ""

    No results matching ""