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 | 9 | public function __construct() |
|
41 | |||
42 | /** |
||
43 | * Set up parameters. |
||
44 | * |
||
45 | * @param array $params |
||
46 | * |
||
47 | * @throws \RuntimeException |
||
48 | */ |
||
49 | 8 | 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 | 5 | public function push(Message $message) |
|
100 | |||
101 | /** |
||
102 | * Get the Stream socket client. |
||
103 | * |
||
104 | * Connect to the APNS server and open a client socket to it. |
||
105 | * |
||
106 | * @return resource Socket to the APNS server. |
||
107 | * |
||
108 | * @throws PushException if connection to APNS server failed. |
||
109 | */ |
||
110 | 3 | private function getStreamSocketClient() |
|
127 | |||
128 | /** |
||
129 | * Get secured stream context from SSL certificate. |
||
130 | * |
||
131 | * @return resource |
||
132 | */ |
||
133 | 3 | private function getStreamContext() |
|
148 | |||
149 | /** |
||
150 | * Write $payload on $stream, it will be sent to given device $token. |
||
151 | * |
||
152 | * @param $payload |
||
153 | * @param $stream |
||
154 | * @param $token |
||
155 | */ |
||
156 | 2 | private function writePayloadOnStreamForGivenToken($payload, $stream, $token) |
|
168 | } |
||
169 |