|
@@ -95,8 +95,8 @@ class room_processor implements IProcessor
|
|
|
elseif($op == 'notice_room') {
|
|
|
return $this->factory_notice_room($bufid,$input);
|
|
|
}
|
|
|
- elseif($op == 'notice_user') {
|
|
|
- return $this->factory_notice_user($bufid,$input);
|
|
|
+ elseif($op == 'notice_users') {
|
|
|
+ return $this->factory_notice_users($bufid,$input);
|
|
|
}
|
|
|
elseif($op == 'notice_all') {
|
|
|
return $this->factory_notice_all($bufid,$input);
|
|
@@ -300,20 +300,68 @@ class room_processor implements IProcessor
|
|
|
return $this->error(errcode::ErrRoomChange);
|
|
|
}
|
|
|
|
|
|
- private function factory_notice_user($bufid, $input)
|
|
|
+ ///Push消息处理区/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ private function factory_notice_users($bufid, $input)
|
|
|
{
|
|
|
+ $content = $input['content'];
|
|
|
+ $msg = $input['msg'];
|
|
|
+ $users = $input['users'];
|
|
|
+
|
|
|
+ $type = $input['type'];
|
|
|
+ if($type === proto_type::push_command) {
|
|
|
+ $pushid = 1;
|
|
|
+ $msg_type = proto_type::msg_type_command;
|
|
|
+ $send = $content;
|
|
|
+ }
|
|
|
+ elseif($type === proto_type::push_notify) {
|
|
|
+ $pushid = 2;
|
|
|
+ $msg_type = proto_type::msg_type_nofity;
|
|
|
+ $send = $msg;
|
|
|
+ }
|
|
|
+ elseif($type === proto_type::push_apply) {
|
|
|
+ $pushid = 3;
|
|
|
+ $msg_type = proto_type::msg_type_apply;
|
|
|
+ $send = $msg;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return $this->error(errcode::ErrParamter);
|
|
|
+ }
|
|
|
+
|
|
|
+ if($msg_type != proto_type::msg_type_command)
|
|
|
+ {
|
|
|
+ $mod_room = Model('room');
|
|
|
|
|
|
+ $orgmsg = json_encode($content);
|
|
|
+ foreach ($users as $user) {
|
|
|
+ $mod_room->addRoomMsg(['room_id' => 0,'member_id' => $user, 'type' => $msg_type,'msg' => $msg, 'orgmsg' => $orgmsg, 'add_time' => time(),'msg_type' => 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->write_push_users($pushid,$users,$send);
|
|
|
+
|
|
|
+ return $this->success(NULL);
|
|
|
}
|
|
|
|
|
|
private function factory_notice_all($bufid, $input)
|
|
|
{
|
|
|
$content = $input['content'];
|
|
|
$type = $input['type'];
|
|
|
+ if($type === proto_type::push_command) {
|
|
|
+ $pushid = 1;
|
|
|
+ }
|
|
|
+ elseif($type === proto_type::push_notify) {
|
|
|
+ $pushid = 2;
|
|
|
+ }
|
|
|
+ elseif($type === proto_type::push_apply) {
|
|
|
+ $pushid = 3;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return $this->error(errcode::ErrParamter);
|
|
|
+ }
|
|
|
|
|
|
$this->write_push($content);
|
|
|
return $this->success(NULL);
|
|
|
}
|
|
|
-
|
|
|
////////////////////////////////////////Access Message Handler//////////////////////////////////////////////////////
|
|
|
private function onAccess($bufid,$input)
|
|
|
{
|
|
@@ -377,6 +425,30 @@ class room_processor implements IProcessor
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ private function write_push_users($pushid,$users,$content)
|
|
|
+ {
|
|
|
+ $msg = [];
|
|
|
+
|
|
|
+ $msg['act'] = "room";
|
|
|
+ $msg['op'] = "relay";
|
|
|
+ $msg['relay_type'] = "users";
|
|
|
+ $msg['receivers'] = $users;
|
|
|
+ $msg['room'] = 0;
|
|
|
+ $msg['receiver_type'] = proto_type::sroom_push;
|
|
|
+ $msg['msgtype'] = "message";
|
|
|
+
|
|
|
+
|
|
|
+ $msg['body']['act'] = proto_type::act_push;
|
|
|
+ $msg['body']['op'] = 'message';
|
|
|
+ $msg['body']['push'] = $pushid;
|
|
|
+ $msg['body']['content'] = $content;
|
|
|
+ $msg['body']['msgtype'] = "message";
|
|
|
+
|
|
|
+ $body = json_encode($msg);
|
|
|
+ foreach ($this->mAccConnes as $conn) {
|
|
|
+ process_looper::instance()->write($conn,$body);
|
|
|
+ }
|
|
|
+ }
|
|
|
private function write_push($content)
|
|
|
{
|
|
|
$msg = [];
|
|
@@ -387,10 +459,14 @@ class room_processor implements IProcessor
|
|
|
$msg['receivers'] = [];
|
|
|
$msg['room'] = 0;
|
|
|
$msg['receiver_type'] = proto_type::sroom_push;
|
|
|
+ $msg['msgtype'] = "message";
|
|
|
+
|
|
|
|
|
|
$msg['body']['act'] = proto_type::act_push;
|
|
|
$msg['body']['op'] = 'message';
|
|
|
+ $msg['body']['push'] = 0;
|
|
|
$msg['body']['content'] = $content;
|
|
|
+ $msg['body']['msgtype'] = "message";
|
|
|
|
|
|
$body = $this->success($msg);
|
|
|
foreach ($this->mAccConnes as $conn) {
|