1 | <?php |
||
10 | abstract class AbstractNotification implements PushNotificationInterface, LifeCycleCallback |
||
11 | { |
||
12 | /** |
||
13 | * @var MessageQueue |
||
14 | */ |
||
15 | protected $messageQueue; |
||
16 | |||
17 | /** |
||
18 | * @var Connection |
||
19 | */ |
||
20 | protected $stream; |
||
21 | |||
22 | /** |
||
23 | * @var CallbackInvoker |
||
24 | */ |
||
25 | protected $invoker; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | protected $retryCount = 3; |
||
31 | |||
32 | /** |
||
33 | * AbstractNotification constructor. |
||
34 | */ |
||
35 | 20 | public function __construct() |
|
40 | |||
41 | 8 | final public function send() |
|
64 | |||
65 | abstract protected function sendImpl(MessageInterface $message); |
||
66 | |||
67 | 6 | public function enqueue(MessageInterface $message) |
|
71 | |||
72 | /** |
||
73 | * @param Connection $wrapper |
||
74 | */ |
||
75 | 9 | public function setStreamWrapper(Connection $wrapper) |
|
79 | |||
80 | /** |
||
81 | * @param int $count |
||
82 | */ |
||
83 | 10 | public function setRetryCount($count) |
|
90 | |||
91 | abstract protected function createPayload(MessageInterface $message); |
||
92 | |||
93 | 6 | final protected function openConnection() |
|
101 | |||
102 | 6 | protected function notifyOnComplete(MessageQueue $message) |
|
106 | |||
107 | 5 | protected function notifyOnEachSent(MessageInterface $message, $feedBack) |
|
111 | |||
112 | 2 | public function onComplete(callable $listener) |
|
116 | |||
117 | 4 | public function onEachSent(callable $callback) |
|
121 | |||
122 | 2 | public function detach() |
|
126 | |||
127 | 6 | private function lazyInitStream() |
|
133 | |||
134 | /** |
||
135 | * @return array |
||
136 | */ |
||
137 | abstract protected function getConnectionParams(); |
||
138 | } |