34
34
use PAMI \Message \Message ;
35
35
use PAMI \Message \IncomingMessage ;
36
36
use PAMI \Message \Action \LoginAction ;
37
- use PAMI \Message \Action \LogoffAction ;
38
37
use PAMI \Message \Response \ResponseMessage ;
39
- use PAMI \Message \Event \EventMessage ;
40
38
use PAMI \Message \Event \Factory \Impl \EventFactoryImpl ;
41
39
use PAMI \Listener \IEventListener ;
42
40
use PAMI \Client \Exception \ClientException ;
@@ -60,7 +58,7 @@ class ClientImpl implements IClient
60
58
{
61
59
/**
62
60
* PSR-3 logger.
63
- * @var Logger
61
+ * @var LoggerInterface
64
62
*/
65
63
private $ logger ;
66
64
@@ -150,6 +148,12 @@ class ClientImpl implements IClient
150
148
*/
151
149
private $ lastActionId ;
152
150
151
+ /**
152
+ * Event mask to apply on login action.
153
+ * @var string|null
154
+ */
155
+ private $ eventMask ;
156
+
153
157
/**
154
158
* Opens a tcp connection to ami.
155
159
*
@@ -173,7 +177,7 @@ public function open()
173
177
if ($ this ->socket === false ) {
174
178
throw new ClientException ('Error connecting to ami: ' . $ errstr );
175
179
}
176
- $ msg = new LoginAction ($ this ->user , $ this ->pass );
180
+ $ msg = new LoginAction ($ this ->user , $ this ->pass , $ this -> eventMask );
177
181
$ asteriskId = @stream_get_line ($ this ->socket , 1024 , Message::EOL );
178
182
if (strstr ($ asteriskId , 'Asterisk ' ) === false ) {
179
183
throw new ClientException (
@@ -434,7 +438,7 @@ public function close()
434
438
/**
435
439
* Sets the logger implementation.
436
440
*
437
- * @param Psr\Log\ LoggerInterface $logger The PSR3-Logger
441
+ * @param LoggerInterface $logger The PSR3-Logger
438
442
*
439
443
* @return void
440
444
*/
@@ -453,12 +457,13 @@ public function __construct(array $options)
453
457
{
454
458
$ this ->logger = new NullLogger ;
455
459
$ this ->host = $ options ['host ' ];
456
- $ this ->port = intval ( $ options ['port ' ]) ;
460
+ $ this ->port = ( int ) $ options ['port ' ];
457
461
$ this ->user = $ options ['username ' ];
458
462
$ this ->pass = $ options ['secret ' ];
459
463
$ this ->cTimeout = $ options ['connect_timeout ' ];
460
464
$ this ->rTimeout = $ options ['read_timeout ' ];
461
465
$ this ->scheme = isset ($ options ['scheme ' ]) ? $ options ['scheme ' ] : 'tcp:// ' ;
466
+ $ this ->eventMask = isset ($ options ['event_mask ' ]) ? $ options ['event_mask ' ] : null ;
462
467
$ this ->eventListeners = array ();
463
468
$ this ->eventFactory = new EventFactoryImpl ();
464
469
$ this ->incomingQueue = array ();
0 commit comments