-
Notifications
You must be signed in to change notification settings - Fork 12
/
Distribute.php
98 lines (89 loc) · 2.37 KB
/
Distribute.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* 聊天室消息分发
*/
namespace RongCloud\Lib\Chatroom\Distribute;
use RongCloud\Lib\Request;
use RongCloud\Lib\Utils;
class Distribute {
/**
* 停止聊天室消息分发路径
*
* @var string
*/
private $jsonPath = 'Lib/Chatroom/Distribute/';
/**
* 请求配置文件
*
* @var string
*/
private $conf = "";
/**
* 校验配置文件
*
* @var string
*/
private $verify = "";
/**
* Distribute constructor.
*/
function __construct()
{
$this->conf = Utils::getJson($this->jsonPath.'api.json');
$this->verify = Utils::getJson($this->jsonPath.'../verify.json');;
}
/**
* 停止聊天室消息分发
*
* @param array $Chatroom
* $Chatroom = [
'id'=> 'ujadk90ha',//聊天室 id
];
* @return mixed|null
*/
public function stop(array $Chatroom=[]){
$conf = $this->conf['stop'];
$verify = $this->verify['chatroom'] ;
$verify = ['id'=>$verify['id']];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'chatroom',
'data'=> $Chatroom,
'verify'=> $verify
]);
if($error) return $error;
$Chatroom = (new Utils())->rename($Chatroom, [
'id'=>'chatroomId',
]);
$result = (new Request())->Request($conf['url'],$Chatroom);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* 恢复聊天室消息分发
*
* @param array $Chatroom
* $Chatroom = [
'id'=> 'ujadk90ha',//聊天室 id
];
* @return mixed|null
*/
public function resume(array $Chatroom=[]){
$conf = $this->conf['resume'];
$verify = $this->verify['chatroom'] ;
$verify = ['id'=>$verify['id']];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'chatroom',
'data'=> $Chatroom,
'verify'=> $verify
]);
if($error) return $error;
$Chatroom = (new Utils())->rename($Chatroom, [
'id'=>'chatroomId',
]);
$result = (new Request())->Request($conf['url'],$Chatroom);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
}