45 'tls://feedback.push.apple.com:2196',
46 'tls://feedback.sandbox.push.apple.com:2196'
68 $nFeedbackTupleLen = self::TIME_BINARY_SIZE + self::TOKEN_LENGTH_BINARY_SIZE + self::DEVICE_BINARY_SIZE;
70 $this->_aFeedback = array();
72 while (!feof($this->_hSocket)) {
73 $this->
_log(
'INFO: Reading...');
74 $sBuffer .= $sCurrBuffer = fread($this->_hSocket, 8192);
75 $nCurrBufferLen = strlen($sCurrBuffer);
76 if ($nCurrBufferLen > 0) {
77 $this->
_log(
"INFO: {$nCurrBufferLen} bytes read.");
79 unset($sCurrBuffer, $nCurrBufferLen);
81 $nBufferLen = strlen($sBuffer);
82 if ($nBufferLen >= $nFeedbackTupleLen) {
83 $nFeedbackTuples = floor($nBufferLen / $nFeedbackTupleLen);
84 for ($i = 0; $i < $nFeedbackTuples; $i++) {
85 $sFeedbackTuple = substr($sBuffer, 0, $nFeedbackTupleLen);
86 $sBuffer = substr($sBuffer, $nFeedbackTupleLen);
88 $this->
_log(sprintf(
"INFO: New feedback tuple: timestamp=%d (%s), tokenLength=%d, deviceToken=%s.",
89 $aFeedback[
'timestamp'], date(
'Y-m-d H:i:s', $aFeedback[
'timestamp']),
90 $aFeedback[
'tokenLength'], $aFeedback[
'deviceToken']
96 $read = array($this->_hSocket);
98 $nChangedStreams = stream_select($read, $null, $null, 0, $this->_nSocketSelectTimeout);
99 if ($nChangedStreams ===
false) {
100 $this->
_log(
'WARNING: Unable to wait for a stream availability.');
115 return unpack(
'Ntimestamp/ntokenLength/H*deviceToken', $sBinaryTuple);
const TIME_BINARY_SIZE
integer Timestamp binary size in bytes.
array _parseBinaryTuple(string $sBinaryTuple)
Parses binary tuples.
const TOKEN_LENGTH_BINARY_SIZE
integer Token length binary size in bytes.
Abstract class: this is the superclass for all Apple Push Notification Service classes.
array receive()
Receives feedback tuples from Apple Push Notification Service feedback.
void _log(string $sMessage)
Logs a message through the Logger.
The Feedback Service client.
$_aServiceURLs
array Feedback URLs environments.
array $_aFeedback
Feedback container.