ts3phpframework
Loading...
Searching...
No Matches
Event.php
Go to the documentation of this file.
1
<?php
2
3
namespace
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery
;
4
5
use ArrayAccess;
6
use
PlanetTeamSpeak\TeamSpeak3Framework\Exception\AdapterException
;
7
use
PlanetTeamSpeak\TeamSpeak3Framework\Exception\NodeException
;
8
use
PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException
;
9
use
PlanetTeamSpeak\TeamSpeak3Framework\Helper\Signal
;
10
use
PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper
;
11
use
PlanetTeamSpeak\TeamSpeak3Framework\Node\Host
;
12
use
PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3
;
13
20
class
Event
implements
ArrayAccess
21
{
27
protected
StringHelper
$type
;
28
34
protected
array
$data
;
35
41
protected
StringHelper
$mesg
;
42
51
public
function
__construct
(
StringHelper
$evt,
Host
$con =
null
)
52
{
53
if
(!$evt->
startsWith
(
TeamSpeak3::EVENT
)) {
54
throw
new
AdapterException
(
"invalid notification event format"
);
55
}
56
57
list(
$type
,
$data
) = $evt->
split
(
TeamSpeak3::SEPARATOR_CELL
, 2);
58
59
if
(empty(
$data
)) {
60
throw
new
AdapterException
(
"invalid notification event data"
);
61
}
62
63
$fake =
new
StringHelper
(
TeamSpeak3::ERROR
.
TeamSpeak3::SEPARATOR_CELL
.
"id"
.
TeamSpeak3::SEPARATOR_PAIR
. 0 .
TeamSpeak3::SEPARATOR_CELL
.
"msg"
.
TeamSpeak3::SEPARATOR_PAIR
.
"ok"
);
64
$repl =
new
Reply
([
$data
, $fake],
$type
);
65
66
$this->type =
$type
->substr(strlen(
TeamSpeak3::EVENT
));
67
$this->data = $repl->toList();
68
$this->mesg =
$data
;
69
70
Signal::getInstance()->emit(
"notifyEvent"
, $this, $con);
71
Signal::getInstance()->emit(
"notify"
. ucfirst($this->type), $this, $con);
72
}
73
79
public
function
getType
():
StringHelper
80
{
81
return
$this->type
;
82
}
83
89
public
function
getData
(): array
90
{
91
return
$this->data
;
92
}
93
99
public
function
getMessage
():
StringHelper
100
{
101
return
$this->mesg
;
102
}
103
107
public
function
offsetExists
($offset): bool
108
{
109
return
array_key_exists($offset, $this->data);
110
}
111
116
public
function
offsetGet
($offset): mixed
117
{
118
if
(!$this->
offsetExists
($offset)) {
119
throw
new
ServerQueryException
(
"invalid parameter"
, 0x602);
120
}
121
122
return
$this->data[$offset];
123
}
124
129
public
function
offsetSet
($offset, $value): void
130
{
131
throw
new
NodeException
(
"event '"
. $this->
getType
() .
"' is read only"
);
132
}
133
137
public
function
offsetUnset
($offset): void
138
{
139
unset($this->data[$offset]);
140
}
141
146
public
function
__get
($offset)
147
{
148
return
$this->
offsetGet
($offset);
149
}
150
155
public
function
__set
($offset, $value)
156
{
157
$this->
offsetSet
($offset, $value);
158
}
159
}
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event
Provides methods to analyze and format a ServerQuery event.
Definition
Event.php:21
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\__construct
__construct(StringHelper $evt, Host $con=null)
Definition
Event.php:51
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\$data
array $data
Definition
Event.php:34
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\offsetExists
offsetExists($offset)
Definition
Event.php:107
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\offsetGet
offsetGet($offset)
Definition
Event.php:116
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\offsetUnset
offsetUnset($offset)
Definition
Event.php:137
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\getData
getData()
Definition
Event.php:89
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\offsetSet
offsetSet($offset, $value)
Definition
Event.php:129
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\getType
getType()
Definition
Event.php:79
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\$mesg
StringHelper $mesg
Definition
Event.php:41
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\getMessage
getMessage()
Definition
Event.php:99
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\$type
StringHelper $type
Definition
Event.php:27
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\__get
__get($offset)
Definition
Event.php:146
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Event\__set
__set($offset, $value)
Definition
Event.php:155
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Reply
Provides methods to analyze and format a ServerQuery reply.
Definition
Reply.php:19
PlanetTeamSpeak\TeamSpeak3Framework\Exception\AdapterException
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\Adapter objects.
Definition
AdapterException.php:12
PlanetTeamSpeak\TeamSpeak3Framework\Exception\NodeException
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Node\Node objects.
Definition
NodeException.php:12
PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.
Definition
ServerQueryException.php:12
PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper
Helper class for string handling.
Definition
StringHelper.php:19
PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper\split
split(string $separator, int $limit=0)
Definition
StringHelper.php:199
PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper\startsWith
startsWith(string $pattern)
Definition
StringHelper.php:100
PlanetTeamSpeak\TeamSpeak3Framework\Node\Host
Class describing a TeamSpeak 3 server instance and all it's parameters.
Definition
Host.php:23
PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3
Factory class all for TeamSpeak 3 PHP Framework objects.
Definition
TeamSpeak3.php:51
PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3\SEPARATOR_CELL
const SEPARATOR_CELL
protocol cell separator
Definition
TeamSpeak3.php:97
PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3\SEPARATOR_PAIR
const SEPARATOR_PAIR
protocol pair separator
Definition
TeamSpeak3.php:98
PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3\EVENT
const EVENT
Definition
TeamSpeak3.php:80
PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3\ERROR
const ERROR
Definition
TeamSpeak3.php:75
PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery
Definition
Event.php:3
PlanetTeamSpeak\TeamSpeak3Framework\Helper\Signal
Definition
Handler.php:3
src
Adapter
ServerQuery
Event.php
Generated by
1.14.0