1 | <?php |
||
23 | class ApnsClient implements ClientInterface |
||
24 | { |
||
25 | use ClientLoggableTrait; |
||
26 | |||
27 | /** |
||
28 | * Push server params. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | private $params; |
||
33 | |||
34 | /** |
||
35 | * Constructor. |
||
36 | */ |
||
37 | 8 | public function __construct() |
|
41 | |||
42 | /** |
||
43 | * Set up parameters. |
||
44 | * |
||
45 | * @param array $params |
||
46 | * |
||
47 | * @throws \RuntimeException |
||
48 | */ |
||
49 | 7 | public function setUp(array $params) |
|
65 | |||
66 | /** |
||
67 | * Send $message to a mobile client. |
||
68 | * |
||
69 | * @param Message $message |
||
70 | * |
||
71 | * @throws \RuntimeException if setUp method was not called. |
||
72 | * @throws PushException if connection to APNS server failed. |
||
73 | */ |
||
74 | 4 | public function push(Message $message) |
|
95 | |||
96 | /** |
||
97 | * Get the Stream socket client. |
||
98 | * |
||
99 | * Connect to the APNS server and open a client socket to it. |
||
100 | * |
||
101 | * @return resource Socket to the APNS server. |
||
102 | * |
||
103 | * @throws PushException if connection to APNS server failed. |
||
104 | */ |
||
105 | 3 | private function getStreamSocketClient() |
|
122 | |||
123 | /** |
||
124 | * Get secured stream context from SSL certificate. |
||
125 | * |
||
126 | * @return resource |
||
127 | */ |
||
128 | 3 | private function getStreamContext() |
|
143 | |||
144 | /** |
||
145 | * Write $payload on $stream, it will be sent to given device $token. |
||
146 | * |
||
147 | * @param $payload |
||
148 | * @param $stream |
||
149 | * @param $token |
||
150 | */ |
||
151 | 2 | private function writePayloadOnStreamForGivenToken($payload, $stream, $token) |
|
163 | } |
||
164 |