|
@@ -36,8 +36,10 @@ class processor implements IProcessor
|
|
|
if(!empty($act) && $act == proto_type::act_factory) {
|
|
|
return $this->onFactory($input);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ elseif(!empty($act) && $act == proto_type::act_access) {
|
|
|
+ return $this->onAccess($input);
|
|
|
+ }
|
|
|
+ else {
|
|
|
return $this->onRoom($input);
|
|
|
}
|
|
|
|
|
@@ -59,9 +61,60 @@ class processor implements IProcessor
|
|
|
|
|
|
return $this->error(errcode::ErrRoomCreate);
|
|
|
}
|
|
|
+
|
|
|
+ private function onAccess($input)
|
|
|
+ {
|
|
|
+ $result['act'] = 'access';
|
|
|
+
|
|
|
+ $op = $input['op'];
|
|
|
+ if($op == 'list')
|
|
|
+ {
|
|
|
+ $result['op'] = 'list';
|
|
|
+ $result['rooms'] = $this->rooms();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function rooms()
|
|
|
+ {
|
|
|
+ $result = [];
|
|
|
+ foreach ($this->mRooms as $roomid => $room) {
|
|
|
+ $result[] = $roomid;
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
private function onRoom($input)
|
|
|
{
|
|
|
-
|
|
|
+ $roomid = intval($input['room_id']);
|
|
|
+ $room = $this->room($roomid);
|
|
|
+ if($room != false)
|
|
|
+ {
|
|
|
+ $function = $input['op'] . 'Op';
|
|
|
+ if (method_exists($room,$function))
|
|
|
+ {
|
|
|
+ $ret = $room->$function($input);
|
|
|
+ if($ret === false) {
|
|
|
+ return $this->error(errcode::ErrRoom);
|
|
|
+ } else {
|
|
|
+ return $this->success($ret);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function room($roomid)
|
|
|
+ {
|
|
|
+ if($roomid <= 0) return false;
|
|
|
+ if(array_key_exists($roomid,$this->mRooms)) {
|
|
|
+ return $this->mRooms[$roomid];
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function success($datas) {
|