|
@@ -42,6 +42,9 @@ class Easemob extends Api
|
|
*
|
|
*
|
|
* 群组和聊天室操作:
|
|
* 群组和聊天室操作:
|
|
*
|
|
*
|
|
|
|
+ * muc:presence 有新成员加入了聊天室
|
|
|
|
+ *{"callId":"1101231101159883#demo_1215090885268604500","channel_channel":"1101231101159883#demo_230909515202562@admin.conference.easemob.com","eventType":"chat","channel_user":"1101231101159883#demo_9@easemob.com","chat_type":"muc","security":"845b22a4edcb4fde2185ff7f0374f051","is_downgrade":false,"content_type":"muc:presence","payload":{"muc_id":"1101231101159883#demo_230909515202562@conference.easemob.com","is_chatroom":true,"operation":"presence"},"group_id":"230909515202562","writed_channel":false,"host":"msync@ebs-ali-beijing-msync105","appkey":"1101231101159883#demo","from":"1101231101159883#demo_9@easemob.com","to":"230909515202562","msg_id":"1215090885268604500","timestamp":1700475192937}
|
|
|
|
+ *
|
|
* muc:kick 踢出聊天室
|
|
* muc:kick 踢出聊天室
|
|
* {"callId":"1101231101159883#demo_1215088856588617164","channel_channel":"1101231101159883#demo_9@easemob.com","eventType":"chat","channel_user":"1101231101159883#demo_231181574537218@admin.conference.easemob.com","chat_type":"muc","security":"83f9462c7769df1c979fd9dea88e7400","is_downgrade":false,"content_type":"muc:kick","payload":{"muc_id":"1101231101159883#demo_231181574537218@conference.easemob.com","reason":"chatroom kick offline user","is_chatroom":true,"operation":"kick","status":{"description":"","error_code":"ok"}},"group_id":"231181574537218","writed_channel":false,"host":"msync@ebs-ali-beijing-msync71","appkey":"1101231101159883#demo","from":"1101231101159883#demo_9@easemob.com","to":"9","msg_id":"1215088856588617164","timestamp":1700474720591}
|
|
* {"callId":"1101231101159883#demo_1215088856588617164","channel_channel":"1101231101159883#demo_9@easemob.com","eventType":"chat","channel_user":"1101231101159883#demo_231181574537218@admin.conference.easemob.com","chat_type":"muc","security":"83f9462c7769df1c979fd9dea88e7400","is_downgrade":false,"content_type":"muc:kick","payload":{"muc_id":"1101231101159883#demo_231181574537218@conference.easemob.com","reason":"chatroom kick offline user","is_chatroom":true,"operation":"kick","status":{"description":"","error_code":"ok"}},"group_id":"231181574537218","writed_channel":false,"host":"msync@ebs-ali-beijing-msync71","appkey":"1101231101159883#demo","from":"1101231101159883#demo_9@easemob.com","to":"9","msg_id":"1215088856588617164","timestamp":1700474720591}
|
|
*
|
|
*
|
|
@@ -185,7 +188,10 @@ class Easemob extends Api
|
|
}
|
|
}
|
|
|
|
|
|
if(isset($payload['operation']) && in_array($payload['operation'],['kick','absence','leave']) ){
|
|
if(isset($payload['operation']) && in_array($payload['operation'],['kick','absence','leave']) ){
|
|
- $operation = true;
|
|
|
|
|
|
+ $operation = 'out';
|
|
|
|
+ }
|
|
|
|
+ if(isset($payload['operation']) && $payload['operation'] = 'presence' ){
|
|
|
|
+ $operation = 'in';
|
|
}
|
|
}
|
|
|
|
|
|
if(isset($payload['status']['error_code']) && $payload['status']['error_code'] == 'ok'){
|
|
if(isset($payload['status']['error_code']) && $payload['status']['error_code'] == 'ok'){
|
|
@@ -200,8 +206,78 @@ class Easemob extends Api
|
|
$uid = $this->get_easemob_uid($input['from']);
|
|
$uid = $this->get_easemob_uid($input['from']);
|
|
}
|
|
}
|
|
|
|
|
|
- if($uid && $room_id && $is_chatroom && $operation && $error_code){
|
|
|
|
- //开始处理
|
|
|
|
|
|
+ //开始处理
|
|
|
|
+
|
|
|
|
+ //进入房间
|
|
|
|
+ if($uid && $room_id && $is_chatroom && $operation == 'in' && $error_code){
|
|
|
|
+ $roomId = $room_id;
|
|
|
|
+ $userId = $uid;
|
|
|
|
+
|
|
|
|
+ $this->redis->hSet("online_" . $roomId, $userId, $userId);
|
|
|
|
+ $this->redis->zAdd("party_user_".$roomId,$userId,0); //新加的
|
|
|
|
+ // 记录在线用户在房间情况
|
|
|
|
+ $this->redis->hSet("livingUser",$userId,$roomId);
|
|
|
|
+
|
|
|
|
+ // 更新房间在线状态
|
|
|
|
+ $partyInfo = $this->redis->get("party_" . $roomId);
|
|
|
|
+ if ($partyInfo) {
|
|
|
|
+ $partyInfo = json_decode($partyInfo, true);
|
|
|
|
+ if ($partyInfo["is_online"] != 1) {
|
|
|
|
+ $partyInfo["is_online"] = 1;
|
|
|
|
+ $this->redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
|
+ \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新房间在线状态
|
|
|
|
+ $liveInfo = $this->redis->get("live_" . $roomId);
|
|
|
|
+ if ($liveInfo) {
|
|
|
|
+ $liveInfo = json_decode($liveInfo, true);
|
|
|
|
+ if ($liveInfo["is_online"] != 1) {
|
|
|
|
+ $liveInfo["is_online"] = 1;
|
|
|
|
+ $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
|
+ \app\common\model\Party::update(["is_online" => 1], ["id" => $roomId]);
|
|
|
|
+ $rs_user = Db::name('user')->where('id',$userId)->update(['is_live'=>1]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //出去房间
|
|
|
|
+ if($uid && $room_id && $is_chatroom && $operation == 'out' && $error_code){
|
|
|
|
+ $roomId = $room_id;
|
|
|
|
+ $userId = $uid;
|
|
|
|
+
|
|
|
|
+ $this->redis->HDel("online_" . $roomId, $userId);
|
|
|
|
+ $this->redis->zRem("party_user_".$roomId,$userId); //新加的
|
|
|
|
+ // 扣除在线用户在房间情况
|
|
|
|
+ $this->redis->hDel("livingUser",$userId);
|
|
|
|
+
|
|
|
|
+ // 更新房间在线状态
|
|
|
|
+ $partyInfo = $this->redis->get("party_" . $roomId);
|
|
|
|
+ if ($partyInfo) {
|
|
|
|
+ $partyInfo = json_decode($partyInfo, true);
|
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
|
+ if ($memCount <= 0) {
|
|
|
|
+ $partyInfo["is_online"] = 0;
|
|
|
|
+ $this->redis->set("party_" . $roomId, json_encode($partyInfo));
|
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ $liveInfo = $this->redis->get("live_" . $roomId);
|
|
|
|
+ if ($liveInfo) {
|
|
|
|
+ $liveInfo = json_decode($liveInfo, true);
|
|
|
|
+ $memCount = count($this->redis->hGetAll("online_" . $roomId));
|
|
|
|
+ if ($memCount <= 0) {
|
|
|
|
+ $liveInfo["is_online"] = 0;
|
|
|
|
+ $this->redis->set("live_" . $roomId, json_encode($liveInfo));
|
|
|
|
+ \app\common\model\Party::update(["is_online" => 0], ["id" => $roomId]);
|
|
|
|
+ $rs_user = Db::name('user')->where('id',$userId)->update(['is_live'=>0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //退出房间获取房间自定义属性
|
|
|
|
+ //清理这个人的麦序
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|