|
@@ -105,7 +105,6 @@ class factory_processor implements IProcessor
|
|
|
if($op == 'create')
|
|
|
{
|
|
|
$ret = $this->mFactory->create($input,$fnew);
|
|
|
-
|
|
|
if($ret != false)
|
|
|
{
|
|
|
$invite = $input['invite'];
|
|
@@ -117,8 +116,11 @@ class factory_processor implements IProcessor
|
|
|
if($roomid <= 0 || $inviter <= 0) {
|
|
|
return $this->error(errcode::ErrRoomCreate);
|
|
|
}
|
|
|
+ if($this->build($roomid,$fnew) == false) {
|
|
|
+ return $this->error(errcode::ErrRoomBuild);
|
|
|
+ }
|
|
|
|
|
|
- $result = $this->invite($roomid,$inviter,[$inviter],$fnew);
|
|
|
+ $result = $this->invite($roomid,$inviter,[$inviter]);
|
|
|
if($result != false) {
|
|
|
$ret = array_merge($ret,$result);
|
|
|
return $this->success($ret);
|
|
@@ -127,10 +129,9 @@ class factory_processor implements IProcessor
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- return $this->success($ret);
|
|
|
+ return $this->error(errcode::ErrRoomCreate);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return $this->error(errcode::ErrRoomCreate);
|
|
|
}
|
|
|
elseif($op == 'invite')
|
|
@@ -143,6 +144,11 @@ class factory_processor implements IProcessor
|
|
|
return $this->error(errcode::ErrRoomInvite);
|
|
|
}
|
|
|
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client == false) {
|
|
|
+ $this->build($roomid);
|
|
|
+ }
|
|
|
+
|
|
|
$ret = $this->invite($roomid,$inviter,$invitees);
|
|
|
if($ret != false) {
|
|
|
return $this->success($ret);
|
|
@@ -150,15 +156,37 @@ class factory_processor implements IProcessor
|
|
|
return $this->error(errcode::ErrRoomInvite);
|
|
|
}
|
|
|
}
|
|
|
+ elseif($op == 'change')
|
|
|
+ {
|
|
|
+ $roomid = intval($input['room']);
|
|
|
+ if($roomid <= 0) {
|
|
|
+ return $this->error(errcode::ErrRoomChange);
|
|
|
+ }
|
|
|
+
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client == false) {
|
|
|
+ $this->build($roomid);
|
|
|
+ }
|
|
|
+ $ret = $this->change($roomid);
|
|
|
+ if($ret != false) {
|
|
|
+ return $this->success($ret);
|
|
|
+ } else {
|
|
|
+ return $this->error(errcode::ErrRoomChange);
|
|
|
+ }
|
|
|
+ }
|
|
|
elseif($op == 'leave')
|
|
|
{
|
|
|
$roomid = intval($input['room']);
|
|
|
$user = intval($input['user']);
|
|
|
|
|
|
if($roomid <= 0 || $user <= 0) {
|
|
|
- return $this->error(errcode::ErrRoomInvite);
|
|
|
+ return $this->error(errcode::ErrRoomLeave);
|
|
|
}
|
|
|
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client == false) {
|
|
|
+ $this->build($roomid);
|
|
|
+ }
|
|
|
$ret = $this->leave($roomid,$user);
|
|
|
if($ret != false) {
|
|
|
return $this->success($ret);
|
|
@@ -183,79 +211,93 @@ class factory_processor implements IProcessor
|
|
|
private function onAccess($bufid,$input)
|
|
|
{
|
|
|
$op = $input['op'];
|
|
|
- if($op == 'who') {
|
|
|
+ if($op == 'who')
|
|
|
+ {
|
|
|
$this->mAccUniquer->add_value($bufid);
|
|
|
return $this->success(['act' => proto_type::act_access,'op' => 'who']);
|
|
|
}
|
|
|
- elseif($op == 'build') {
|
|
|
+ elseif($op == 'build')
|
|
|
+ {
|
|
|
$roomid = intval($input['room']);
|
|
|
- $ret = $this->build($roomid);
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client == false) {
|
|
|
+ $this->build($roomid);
|
|
|
+ }
|
|
|
return $this->success(['act' => proto_type::act_access,'op' => $op,'room' => $roomid]);
|
|
|
}
|
|
|
else {
|
|
|
return $this->error(errcode::ErrParamter);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
- private function invite($roomid, $inviter,$invitees,$newroom)
|
|
|
+ private function find_room($roomid,&$outbufid)
|
|
|
{
|
|
|
foreach ($this->mBufidRooms as $bufid => $client)
|
|
|
{
|
|
|
- if($client->contain_room($roomid))
|
|
|
- {
|
|
|
- $this->block($bufid);
|
|
|
- $ret = $client->invite($roomid,$inviter,$invitees,$newroom);
|
|
|
- $this->unblock($bufid);
|
|
|
-
|
|
|
- return $ret;
|
|
|
+ if($client->contain_room($roomid)) {
|
|
|
+ $outbufid = $bufid;
|
|
|
+ return $client;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function build($roomid,$newroom = false)
|
|
|
+ {
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client != false) {
|
|
|
+ $this->block($bufid);
|
|
|
+ $ret = $client->build($roomid,$newroom);
|
|
|
+ $this->unblock($bufid);
|
|
|
+
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+
|
|
|
$bufid = $this->room_bufid();
|
|
|
if($bufid != false)
|
|
|
{
|
|
|
$client = $this->mBufidRooms[$bufid];
|
|
|
$this->block($bufid);
|
|
|
- $ret = $client->invite($roomid,$inviter,$invitees,$newroom);
|
|
|
+ $ret = $client->build($roomid,$newroom);
|
|
|
$this->unblock($bufid);
|
|
|
|
|
|
if($ret != false) {
|
|
|
$client->add_room($roomid);
|
|
|
}
|
|
|
+ return $ret;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- return $ret;
|
|
|
}
|
|
|
- private function build($roomid)
|
|
|
+
|
|
|
+ private function invite($roomid, $inviter,$invitees)
|
|
|
{
|
|
|
- foreach ($this->mBufidRooms as $bufid => $client)
|
|
|
- {
|
|
|
- if($client->contain_room($roomid))
|
|
|
- {
|
|
|
- $this->block($bufid);
|
|
|
- $ret = $client->build($roomid);
|
|
|
- $this->unblock($bufid);
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client != false) {
|
|
|
+ $this->block($bufid);
|
|
|
+ $ret = $client->invite($roomid,$inviter,$invitees);
|
|
|
+ $this->unblock($bufid);
|
|
|
|
|
|
- return $ret;
|
|
|
- }
|
|
|
+ return $ret;
|
|
|
}
|
|
|
|
|
|
- $bufid = $this->room_bufid();
|
|
|
- if($bufid != false)
|
|
|
- {
|
|
|
- $client = $this->mBufidRooms[$bufid];
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ private function change($roomid)
|
|
|
+ {
|
|
|
+ $client = $this->find_room($roomid,$bufid);
|
|
|
+ if($client != false) {
|
|
|
$this->block($bufid);
|
|
|
- $ret = $client->build($roomid);
|
|
|
+ $ret = $client->change($roomid);
|
|
|
$this->unblock($bufid);
|
|
|
|
|
|
- if($ret != false) {
|
|
|
- $client->add_room($roomid);
|
|
|
- }
|
|
|
return $ret;
|
|
|
}
|
|
|
- else {
|
|
|
- return false;
|
|
|
- }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
private function leave($roomid, $user)
|