1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Ssdp project. |
4
|
|
|
* |
5
|
|
|
* @author Daniel Schröder <[email protected]> |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace GravityMedia\Ssdp\Event; |
9
|
|
|
|
10
|
|
|
use GravityMedia\Ssdp\Exception\DiscoverException; |
11
|
|
|
use Psr\Http\Message\UriInterface; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\EventDispatcher\Event; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Discover event class |
17
|
|
|
* |
18
|
|
|
* @package GravityMedia\Ssdp |
19
|
|
|
*/ |
20
|
|
|
class DiscoverEvent extends Event |
21
|
|
|
{ |
22
|
|
|
const EVENT_DISCOVER = 'ssdp:discover'; |
23
|
|
|
const EVENT_DISCOVER_ERROR = 'ssdp:discover:error'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var DiscoverException |
27
|
|
|
*/ |
28
|
|
|
protected $exception; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
protected $lifetime; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var \DateTimeInterface |
37
|
|
|
*/ |
38
|
|
|
protected $date; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var UriInterface |
42
|
|
|
*/ |
43
|
|
|
protected $descriptionUrl; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $serverString; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string |
52
|
|
|
*/ |
53
|
|
|
protected $searchTargetString; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
*/ |
58
|
|
|
protected $uniqueServiceNameString; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var string |
62
|
|
|
*/ |
63
|
|
|
protected $remote; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get exception |
67
|
|
|
* |
68
|
|
|
* @return DiscoverException |
69
|
|
|
*/ |
70
|
|
|
public function getException() |
71
|
|
|
{ |
72
|
|
|
return $this->exception; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Set exception |
77
|
|
|
* |
78
|
|
|
* @param DiscoverException $exception |
79
|
|
|
* |
80
|
|
|
* @return $this |
81
|
|
|
*/ |
82
|
|
|
public function setException(DiscoverException $exception) |
83
|
|
|
{ |
84
|
|
|
$this->exception = $exception; |
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Get lifetime |
90
|
|
|
* |
91
|
|
|
* @return int |
92
|
|
|
*/ |
93
|
|
|
public function getLifetime() |
94
|
|
|
{ |
95
|
|
|
return $this->lifetime; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Set lifetime |
100
|
|
|
* |
101
|
|
|
* @param int $lifetime |
102
|
|
|
* |
103
|
|
|
* @return $this |
104
|
|
|
*/ |
105
|
|
|
public function setLifetime($lifetime) |
106
|
|
|
{ |
107
|
|
|
$this->lifetime = $lifetime; |
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Get date |
113
|
|
|
* |
114
|
|
|
* @return \DateTimeInterface |
115
|
|
|
*/ |
116
|
|
|
public function getDate() |
117
|
|
|
{ |
118
|
|
|
return $this->date; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Set date |
123
|
|
|
* |
124
|
|
|
* @param \DateTimeInterface $date |
125
|
|
|
* |
126
|
|
|
* @return $this |
127
|
|
|
*/ |
128
|
|
|
public function setDate(\DateTimeInterface $date) |
129
|
|
|
{ |
130
|
|
|
$this->date = $date; |
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get description URL |
136
|
|
|
* |
137
|
|
|
* @return UriInterface |
138
|
|
|
*/ |
139
|
|
|
public function getDescriptionUrl() |
140
|
|
|
{ |
141
|
|
|
return $this->descriptionUrl; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Set description URL |
146
|
|
|
* |
147
|
|
|
* @param UriInterface $descriptionUrl |
148
|
|
|
* |
149
|
|
|
* @return $this |
150
|
|
|
*/ |
151
|
|
|
public function setDescriptionUrl(UriInterface $descriptionUrl) |
152
|
|
|
{ |
153
|
|
|
$this->descriptionUrl = $descriptionUrl; |
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Get server string |
159
|
|
|
* |
160
|
|
|
* @return string |
161
|
|
|
*/ |
162
|
|
|
public function getServerString() |
163
|
|
|
{ |
164
|
|
|
return $this->serverString; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Set server string |
169
|
|
|
* |
170
|
|
|
* @param string $serverString |
171
|
|
|
* |
172
|
|
|
* @return $this |
173
|
|
|
*/ |
174
|
|
|
public function setServerString($serverString) |
175
|
|
|
{ |
176
|
|
|
$this->serverString = $serverString; |
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Get search target |
182
|
|
|
* |
183
|
|
|
* @return string |
184
|
|
|
*/ |
185
|
|
|
public function getSearchTargetString() |
186
|
|
|
{ |
187
|
|
|
return $this->searchTargetString; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Set search target |
192
|
|
|
* |
193
|
|
|
* @param string $searchTargetString |
194
|
|
|
* |
195
|
|
|
* @return $this |
196
|
|
|
*/ |
197
|
|
|
public function setSearchTargetString($searchTargetString) |
198
|
|
|
{ |
199
|
|
|
$this->searchTargetString = $searchTargetString; |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Get unique service name |
205
|
|
|
* |
206
|
|
|
* @return string |
207
|
|
|
*/ |
208
|
|
|
public function getUniqueServiceNameString() |
209
|
|
|
{ |
210
|
|
|
return $this->uniqueServiceNameString; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Set unique service name |
215
|
|
|
* |
216
|
|
|
* @param string $uniqueServiceNameString |
217
|
|
|
* |
218
|
|
|
* @return $this |
219
|
|
|
*/ |
220
|
|
|
public function setUniqueServiceNameString($uniqueServiceNameString) |
221
|
|
|
{ |
222
|
|
|
$this->uniqueServiceNameString = $uniqueServiceNameString; |
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Get remote |
228
|
|
|
* |
229
|
|
|
* @return string |
230
|
|
|
*/ |
231
|
|
|
public function getRemote() |
232
|
|
|
{ |
233
|
|
|
return $this->remote; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Set remote |
238
|
|
|
* |
239
|
|
|
* @param string $remote |
240
|
|
|
* |
241
|
|
|
* @return $this |
242
|
|
|
*/ |
243
|
|
|
public function setRemote($remote) |
244
|
|
|
{ |
245
|
|
|
$this->remote = $remote; |
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
} |
249
|
|
|
|