ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilChatroomServerConnector Class Reference

Class ilChatroomServerConnector. More...

+ Collaboration diagram for ilChatroomServerConnector:

Public Member Functions

 __construct (ilChatroomServerSettings $settings)
 Constructor Sets $this->settings using given $settings.
 connect ($scope, $userId)
 Returns connect URL Creates connect URL using given $scope and $userId and returns it.
 post ($scope, $query)
 Returns post URL Creates post URL using given $scope and $query and returns it.
 enterPrivateRoom ($scope, $query)
 leavePrivateRoom ($scope, $query)
 kick ($scope, $query)
 Returns kick URL Creates kick URL using given $scope and $query and returns it.
 getSettings ()
 Returns $this->settings.
 sendMessage ($scope, $message, $options=array())
 Returns if given message is sucessfully sent.
 inviteToPrivateRoom (ilChatRoom $room, $scope, ilObjUser $inviter, $invited_id)
 createPrivateRoom (ilChatroom $room, $title, ilChatroomUser $owner)
 isServerAlive ()

Static Public Member Functions

static checkServerConnection ()

Private Member Functions

 file_get_contents ($url, array $stream_context_params=null)
 sendCreatePrivateRoom ($scope, $query)

Private Attributes

 $settings

Detailed Description

Constructor & Destructor Documentation

ilChatroomServerConnector::__construct ( ilChatroomServerSettings  $settings)

Constructor Sets $this->settings using given $settings.

Parameters
ilChatroomServerSettings$settings

Definition at line 22 of file class.ilChatroomServerConnector.php.

References $settings.

{
$this->settings = $settings;
}

Member Function Documentation

static ilChatroomServerConnector::checkServerConnection ( )
static
Returns
bool

Definition at line 280 of file class.ilChatroomServerConnector.php.

References $settings.

Referenced by ilChatroomBlockGUI\getHTML().

{
require_once 'Modules/Chatroom/classes/class.ilChatroomAdmin.php';
$settings = ilChatroomAdmin::getDefaultConfiguration()->getServerSettings();
return $connector->isServerAlive();
}

+ Here is the caller graph for this function:

ilChatroomServerConnector::connect (   $scope,
  $userId 
)

Returns connect URL Creates connect URL using given $scope and $userId and returns it.

Parameters
string$scope
integer$userId
Returns
mixed

Definition at line 58 of file class.ilChatroomServerConnector.php.

References file_get_contents().

{
return $this->file_get_contents(
$this->settings->getURL('Connect', $scope) . '?id=' . $userId
);
}

+ Here is the call graph for this function:

ilChatroomServerConnector::createPrivateRoom ( ilChatroom  $room,
  $title,
ilChatroomUser  $owner 
)
Parameters
ilChatroom$room
string$title
ilChatroomUser$owner
Returns
mixed

Definition at line 208 of file class.ilChatroomServerConnector.php.

References $query, $result, $settings, ilChatroom\addPrivateRoom(), enterPrivateRoom(), ilChatroom\getRoomId(), ilChatroomUser\getUserId(), sendCreatePrivateRoom(), sendMessage(), and ilChatroom\subscribeUserToPrivateRoom().

{
$settings = array(
'public' => false,
);
$params['user'] = $owner->getUserId();
$params['id'] = $room->addPrivateRoom($title, $owner, $settings);
$query = http_build_query($params);
$response = $this->sendCreatePrivateRoom($room->getRoomId(), $query);
$responseObject = json_decode($response);
$return = $responseObject;
if($responseObject->success == true)
{
$message = json_encode(array(
'type' => 'private_room_created',
'timestamp' => date('c'),
'public' => 0,
'title' => $title,
'id' => $responseObject->id,
'proom_id' => $responseObject->id,
'owner' => $owner->getUserId(),
));
$result = $this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $owner->getUserId()));
$params = array();
$params['user'] = $owner->getUserId();
$params['sub'] = $responseObject->id;
$query = http_build_query($params);
$response = $this->enterPrivateRoom($room->getRoomId(), $query);
$room->subscribeUserToPrivateRoom($params['sub'], $params['user']);
$message = json_encode(array(
'type' => 'private_room_entered',
'user' => $owner->getUserId(),
'timestamp' => date('c'),
'sub' => $responseObject->id
));
$this->sendMessage($room->getRoomId(), $message);
}
return $responseObject;
}

+ Here is the call graph for this function:

ilChatroomServerConnector::enterPrivateRoom (   $scope,
  $query 
)
Parameters
string$scope
string$query
Returns
mixed

Definition at line 96 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

Referenced by createPrivateRoom().

{
return $this->file_get_contents(
$this->settings->getURL('EnterPrivateRoom', $scope) . '?' . $query
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::file_get_contents (   $url,
array  $stream_context_params = null 
)
private
Parameters
string$url
array$stream_context_params
Returns
string

Definition at line 32 of file class.ilChatroomServerConnector.php.

Referenced by connect(), enterPrivateRoom(), isServerAlive(), kick(), leavePrivateRoom(), post(), and sendCreatePrivateRoom().

{
$ctx = array(
'http' => array(
'header' => 'Connection: close'
),
'https' => array(
'header' => 'Connection: close'
)
);
if(is_array($stream_context_params))
{
$ctx = array_merge_recursive($ctx, $stream_context_params);
}
return file_get_contents($url, null, stream_context_create($ctx));
}

+ Here is the caller graph for this function:

ilChatroomServerConnector::getSettings ( )

Returns $this->settings.

Returns
ilChatroomServerSettings

Definition at line 133 of file class.ilChatroomServerConnector.php.

References $settings.

{
}
ilChatroomServerConnector::inviteToPrivateRoom ( ilChatRoom  $room,
  $scope,
ilObjUser  $inviter,
  $invited_id 
)
Parameters
ilChatRoom$room
int$scope
ilObjUser$inviter
int$invited_id
Returns
array

Definition at line 161 of file class.ilChatroomServerConnector.php.

References ilObject\getId(), ilChatroom\lookupPrivateRoomTitle(), and sendMessage().

{
$chat_user = new ilChatroomUser($inviter, $room);
$user_id = $chat_user->getUserId();
if($scope)
{
$room->inviteUserToPrivateRoom($invited_id, $scope);
$message = json_encode(array(
'type' => 'private_room_created',
'users' => $invited_id, //$users,
'timestamp' => date('c'),
'public' => 0,
'proom_id' => $scope,
'message' => array(
'public' => '0',
'user' => 'system',
'owner' => $user_id
)
));
$this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id));
}
if($room->isSubscribed($user_id))
{
$message = json_encode(array(
'type' => 'user_invited',
'proom_id' => $scope,
'inviter' => $inviter->getId(),
'invited' => $invited_id
));
$this->sendMessage($room->getRoomId(), $message, array('public' => 0, 'recipients' => $invited_id));
}
return array('success' => true, 'message' => 'users invited');
}

+ Here is the call graph for this function:

ilChatroomServerConnector::isServerAlive ( )
Returns
bool

Definition at line 258 of file class.ilChatroomServerConnector.php.

References file_get_contents().

{
$response = @$this->file_get_contents(
$this->settings->getURL('Status', 0),
array(
'http' => array(
'timeout' => 2
),
'https' => array(
'timeout' => 2
)
)
);
$responseObject = json_decode($response);
return $responseObject->success == true;
}

+ Here is the call graph for this function:

ilChatroomServerConnector::kick (   $scope,
  $query 
)

Returns kick URL Creates kick URL using given $scope and $query and returns it.

Parameters
string$scope
string$query
Returns
mixed

Definition at line 122 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

{
return $this->file_get_contents(
$this->settings->getURL('Kick', $scope) . '?' . $query
);
}

+ Here is the call graph for this function:

ilChatroomServerConnector::leavePrivateRoom (   $scope,
  $query 
)
Parameters
string$scope
string$query
Returns
mixed

Definition at line 108 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

{
return $this->file_get_contents(
$this->settings->getURL('LeavePrivateRoom', $scope) . '?' . $query
);
}

+ Here is the call graph for this function:

ilChatroomServerConnector::post (   $scope,
  $query 
)

Returns post URL Creates post URL using given $scope and $query and returns it.

Parameters
string$scope
string$query
Returns
mixed

Definition at line 72 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

Referenced by sendMessage().

{
return $this->file_get_contents(
$this->settings->getURL('Post', $scope) . '?' . $query
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::sendCreatePrivateRoom (   $scope,
  $query 
)
private
Parameters
string$scope
string$query
Returns
mixed

Definition at line 84 of file class.ilChatroomServerConnector.php.

References $query, and file_get_contents().

Referenced by createPrivateRoom().

{
return $this->file_get_contents(
$this->settings->getURL('CreatePrivateRoom', $scope) . '?' . $query
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilChatroomServerConnector::sendMessage (   $scope,
  $message,
  $options = array() 
)

Returns if given message is sucessfully sent.

Calls $this->post using given $scope and $query built by http_build_query with given $message and returns if message was sent sucessfully.

Parameters
string$scope
string$message
Returns
stdClass

Definition at line 147 of file class.ilChatroomServerConnector.php.

References $options, $query, and post().

Referenced by createPrivateRoom(), and inviteToPrivateRoom().

{
$query = http_build_query(array('message' => $message) + $options);
$response = $this->post($scope, $query);
return @json_decode($response);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilChatroomServerConnector::$settings
private

The documentation for this class was generated from the following file: