|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright 2014 Brian Smith <[email protected]>. |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace phparia\Events; |
|
20
|
|
|
|
|
21
|
|
|
use DateTime; |
|
22
|
|
|
use phparia\Client\AriClient; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Base type for asynchronous events from Asterisk. |
|
26
|
|
|
* |
|
27
|
|
|
* @author Brian Smith <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class Event extends Message implements EventInterface |
|
30
|
|
|
{ |
|
31
|
|
|
// ARI events |
|
32
|
|
|
const APPLICATION_REPLACED = 'ApplicationReplaced'; |
|
33
|
|
|
const BRIDGE_ATTENDED_TRANSFER = 'BridgeAttendedTransfer'; |
|
34
|
|
|
const BRIDGE_BLIND_TRANSFER = 'BridgeBlindTransfer'; |
|
35
|
|
|
const BRIDGE_CREATED = 'BridgeCreated'; |
|
36
|
|
|
const BRIDGE_DESTROYED = 'BridgeDestroyed'; |
|
37
|
|
|
const BRIDGE_MERGED = 'BridgeMerged'; |
|
38
|
|
|
const CHANNEL_CALLER_ID = 'ChannelCallerId'; |
|
39
|
|
|
const CHANNEL_CREATED = 'ChannelCreated'; |
|
40
|
|
|
const CHANNEL_CONNECTED_LINE = 'ChannelConnectedLine'; |
|
41
|
|
|
const CHANNEL_DESTROYED = 'ChannelDestroyed'; |
|
42
|
|
|
const CHANNEL_DTMF_RECEIVED = 'ChannelDtmfReceived'; |
|
43
|
|
|
const CHANNEL_ENTERED_BRIDGE = 'ChannelEnteredBridge'; |
|
44
|
|
|
const CHANNEL_HANGUP_REQUEST = 'ChannelHangupRequest'; |
|
45
|
|
|
const CHANNEL_LEFT_BRIDGE = 'ChannelLeftBridge'; |
|
46
|
|
|
const CHANNEL_STATE_CHANGED = 'ChannelStateChanged'; |
|
47
|
|
|
const CHANNEL_TALKING_FINISHED = 'ChannelTalkingFinished'; |
|
48
|
|
|
const CHANNEL_TALKING_STARTED = 'ChannelTalkingStarted'; |
|
49
|
|
|
const CHANNEL_USEREVENT = 'ChannelUserevent'; |
|
50
|
|
|
const CHANNEL_VARSET = 'ChannelVarset'; |
|
51
|
|
|
const DEVICE_STATE_CHANGE = 'DeviceStateChange'; |
|
52
|
|
|
const DIAL = 'Dial'; |
|
53
|
|
|
const DIALED = 'Dialed'; |
|
54
|
|
|
const ENDPOINT_STATE_CHANGE = 'EndpointStateChange'; |
|
55
|
|
|
const PLAYBACK_FINISHED = 'PlaybackFinished'; |
|
56
|
|
|
const PLAYBACK_STARTED = 'PlaybackStarted'; |
|
57
|
|
|
const RECORDING_FAILED = 'RecordingFailed'; |
|
58
|
|
|
const RECORDING_FINISHED = 'RecordingFinished'; |
|
59
|
|
|
const RECORDING_STARTED = 'RecordingStarted'; |
|
60
|
|
|
const STASIS_END = 'StasisEnd'; |
|
61
|
|
|
const STASIS_START = 'StasisStart'; |
|
62
|
|
|
const TEXT_MESSAGE_RECEIVED = 'TextMessageReceived'; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var AriClient |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $client; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var string Name of the application receiving the event. |
|
71
|
|
|
*/ |
|
72
|
|
|
private $application; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var DateTime (optional) - Time at which this event was created. |
|
76
|
|
|
*/ |
|
77
|
|
|
private $timestamp; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return string Name of the application receiving the event. |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getApplication() |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->application; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return \DateTime (optional) - Time at which this event was created. |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getTimestamp() |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->timestamp; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param AriClient $client |
|
97
|
|
|
* @param string $response |
|
98
|
|
|
*/ |
|
99
|
38 |
|
public function __construct(AriClient $client, $response) |
|
100
|
|
|
{ |
|
101
|
38 |
|
$this->client = $client; |
|
102
|
|
|
|
|
103
|
38 |
|
parent::__construct($response); |
|
104
|
|
|
|
|
105
|
38 |
|
$this->application = $this->getResponseValue('application'); |
|
106
|
38 |
|
$this->timestamp = $this->getResponseValue('timestamp', '\DateTime'); |
|
107
|
38 |
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|