|
@@ -48,18 +48,41 @@ class processor implements IProcessor
|
|
|
|
|
|
private function onFactory($input)
|
|
|
{
|
|
|
- $room = $this->mFactory->create($input);
|
|
|
- if($room != false) {
|
|
|
- $user = intval($input['creator']);
|
|
|
- $this->mRooms[$room->room_id()] = $room;
|
|
|
- $user_roomKey = $room->invite($user);
|
|
|
- if($user_roomKey != false) {
|
|
|
- $ret = ['room_id' => $room->room_id(),'room_key' => $user_roomKey];
|
|
|
- return $this->success($ret);
|
|
|
+ $err = errcode::ErrRoom;
|
|
|
+ $op = $input['op'];
|
|
|
+ if($op == 'create')
|
|
|
+ {
|
|
|
+ $room = $this->mFactory->create($input);
|
|
|
+ if($room != false) {
|
|
|
+ $user = intval($input['creator']);
|
|
|
+ $this->mRooms[$room->room_id()] = $room;
|
|
|
+ $user_roomKey = $room->invite($user);
|
|
|
+ if($user_roomKey != false) {
|
|
|
+ $ret = ['room' => $room->room_id(),'room_key' => $user_roomKey];
|
|
|
+ return $this->success($ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $err = errcode::ErrRoomCreate;
|
|
|
+ }
|
|
|
+ elseif($op == 'invite')
|
|
|
+ {
|
|
|
+ $roomid = intval($input['room']);
|
|
|
+ $room = $this->room($roomid);
|
|
|
+ if($room != false)
|
|
|
+ {
|
|
|
+ $userid = intval($input['user']);
|
|
|
+ if($userid > 0)
|
|
|
+ {
|
|
|
+ $room_key = $room->invite($userid);
|
|
|
+ if($room_key != false) {
|
|
|
+ return $this->success(['room' => $roomid,'room_key' => $room_key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ $err = errcode::ErrRoomInvite;
|
|
|
}
|
|
|
|
|
|
- return $this->error(errcode::ErrRoomCreate);
|
|
|
+ return $this->error($err);
|
|
|
}
|
|
|
|
|
|
private function onAccess($input)
|
|
@@ -90,21 +113,33 @@ class processor implements IProcessor
|
|
|
|
|
|
private function onRoom($input)
|
|
|
{
|
|
|
- $roomid = intval($input['room_id']);
|
|
|
+ $result['act'] = 'room';
|
|
|
+
|
|
|
+ $roomid = intval($input['room']);
|
|
|
$room = $this->room($roomid);
|
|
|
if($room != false)
|
|
|
{
|
|
|
$function = $input['op'] . 'Op';
|
|
|
+ $roomkey = $input['room_key'];
|
|
|
+
|
|
|
+ $result['room_key'] = $roomkey;
|
|
|
if (method_exists($room,$function))
|
|
|
{
|
|
|
- $ret = $room->$function($input);
|
|
|
- if($ret === false) {
|
|
|
- return $this->error(errcode::ErrRoom);
|
|
|
- } else {
|
|
|
- return $this->success($ret);
|
|
|
+ $msgs = $room->$function($input);
|
|
|
+ if($msgs === false) {
|
|
|
+ $result['op'] = 'deluser';
|
|
|
+ return $this->success($result);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $result['msgs'] = $msgs;
|
|
|
+ $result['op'] = 'broadcast';
|
|
|
+ return $this->success($result);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function room($roomid)
|