|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* OpenFireRestAPI is based entirely on official documentation of the REST API |
|
4
|
|
|
* Plugin and you can extend it by following the directives of the documentation |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. For the full list of |
|
8
|
|
|
* contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors |
|
9
|
|
|
* |
|
10
|
|
|
* @author Luca Agnello <[email protected]> |
|
11
|
|
|
* @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Gnello\OpenFireRestAPI\Endpoints; |
|
15
|
|
|
|
|
16
|
|
|
use \Gnello\OpenFireRestAPI\Dispatcher\Method; |
|
17
|
|
|
use \Gnello\OpenFireRestAPI\Dispatcher\Dispatcher; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Session related REST Endpoint |
|
21
|
|
|
* Class SessionEndpoint |
|
22
|
|
|
* @package Gnello\OpenFireRestAPI\Endpoints |
|
23
|
|
|
* @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#session-related-rest-endpoints |
|
24
|
|
|
*/ |
|
25
|
|
|
class SessionEndpoint extends Dispatcher |
|
26
|
|
|
{ |
|
27
|
|
|
public static $endpoint = '/sessions'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Get all user sessions |
|
31
|
|
|
* @return array with Sessions |
|
32
|
|
|
* @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-all-user-session |
|
33
|
|
|
*/ |
|
34
|
|
|
public static function retrieveAllUserSession() |
|
35
|
|
|
{ |
|
36
|
|
|
return self::sendRequest(Method::GET, self::$endpoint); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get sessions from a user |
|
41
|
|
|
* @param $username |
|
42
|
|
|
* @return array with Sessions |
|
43
|
|
|
* @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#retrieve-the-user-sessions |
|
44
|
|
|
*/ |
|
45
|
|
|
public static function retrieveUserSessions($username) |
|
46
|
|
|
{ |
|
47
|
|
|
$endpoint = self::$endpoint . '/' . $username; |
|
48
|
|
|
return self::sendRequest(Method::GET, $endpoint); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Close/kick sessions from a user |
|
53
|
|
|
* @param $username |
|
54
|
|
|
* @return array with HTTP status 200 (OK) |
|
55
|
|
|
* @link http://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#close-all-user-sessions |
|
56
|
|
|
*/ |
|
57
|
|
|
public static function closeAllUserSessions($username) |
|
58
|
|
|
{ |
|
59
|
|
|
$endpoint = self::$endpoint . '/' . $username; |
|
60
|
|
|
return self::sendRequest(Method::DELETE, $endpoint); |
|
61
|
|
|
} |
|
62
|
|
|
} |