apns-php
|
Abstract class: this is the superclass for all Apple Push Notification Service classes. More...
Public Member Functions | |
void | __construct (integer $nEnvironment, string $sProviderCertificateFile) |
Constructor. More... | |
void | connect () |
Connects to Apple Push Notification service server. More... | |
boolean | disconnect () |
Disconnects from Apple Push Notifications service server. More... | |
string | getCertificateAuthority () |
Get the Root Certification Authority file path. More... | |
integer | getConnectRetryInterval () |
Get the connect retry interval. More... | |
integer | getConnectRetryTimes () |
Get the connect retry time value. More... | |
integer | getConnectTimeout () |
Get the connection timeout. More... | |
ApnsPHP_Log_Interface | getLogger () |
Get the Logger instance. More... | |
integer | getSocketSelectTimeout () |
Get the TCP socket select timeout. More... | |
integer | getWriteInterval () |
Get the write interval. More... | |
void | setConnectRetryInterval (integer $nRetryInterval) |
Set the connect retry interval. More... | |
void | setConnectRetryTimes (integer $nRetryTimes) |
Set the connect retry times value. More... | |
void | setConnectTimeout (integer $nTimeout) |
Set the connection timeout. More... | |
void | setLogger (ApnsPHP_Log_Interface $logger) |
Set the Logger instance to use for logging purpose. More... | |
void | setProviderCertificatePassphrase (string $sProviderCertificatePassphrase) |
Set the Provider Certificate passphrase. More... | |
void | setRootCertificationAuthority (string $sRootCertificationAuthorityFile) |
Set the Root Certification Authority file. More... | |
void | setSocketSelectTimeout (integer $nSelectTimeout) |
Set the TCP socket select timeout. More... | |
void | setWriteInterval (integer $nWriteInterval) |
Set the write interval. More... | |
Data Fields | |
const | CONNECT_RETRY_INTERVAL = 1000000 |
integer Default connect retry interval in micro seconds. More... | |
const | DEVICE_BINARY_SIZE = 32 |
integer Device token length. More... | |
const | ENVIRONMENT_PRODUCTION = 0 |
integer Production environment. More... | |
const | ENVIRONMENT_SANDBOX = 1 |
integer Sandbox environment. More... | |
const | SOCKET_SELECT_TIMEOUT = 1000000 |
integer Default socket select timeout in micro seconds. More... | |
const | WRITE_INTERVAL = 10000 |
integer Default write interval in micro seconds. More... | |
Protected Member Functions | |
boolean | _connect () |
Connects to Apple Push Notification service server. More... | |
void | _log (string $sMessage) |
Logs a message through the Logger. More... | |
Protected Attributes | |
array | $_aServiceURLs = array() |
Container for service URLs environments. More... | |
resource | $_hSocket |
SSL Socket. More... | |
ApnsPHP_Log_Interface | $_logger |
Logger. More... | |
integer | $_nConnectRetryInterval |
Connect retry interval in micro seconds. More... | |
integer | $_nConnectRetryTimes = 3 |
Connect retry times. More... | |
integer | $_nConnectTimeout |
Connect timeout in seconds. More... | |
integer | $_nEnvironment |
Active environment. More... | |
integer | $_nSocketSelectTimeout |
Socket select timeout in micro seconds. More... | |
integer | $_nWriteInterval |
Write interval in micro seconds. More... | |
string | $_sProviderCertificateFile |
Provider certificate file with key (Bundled PEM). More... | |
string | $_sProviderCertificatePassphrase |
Provider certificate passphrase. More... | |
string | $_sRootCertificationAuthorityFile |
Root certification authority file. More... | |
Abstract class: this is the superclass for all Apple Push Notification Service classes.
This class is responsible for the connection to the Apple Push Notification Service and Feedback.
Definition at line 40 of file Abstract.php.
void __construct | ( | integer | $nEnvironment, |
string | $sProviderCertificateFile | ||
) |
Constructor.
$nEnvironment | Environment. |
$sProviderCertificateFile | Provider certificate file with key (Bundled PEM). |
ApnsPHP_Exception | if the environment is not sandbox or production or the provider certificate file is not readable. |
Definition at line 79 of file Abstract.php.
|
protected |
Connects to Apple Push Notification service server.
ApnsPHP_Exception | if is unable to connect. |
Definition at line 371 of file Abstract.php.
References $_nEnvironment, and _log().
Referenced by connect().
|
protected |
Logs a message through the Logger.
$sMessage | The message. |
Definition at line 414 of file Abstract.php.
Referenced by _connect(), ApnsPHP_Push_Server::_mainLoop(), ApnsPHP_Push::_updateQueue(), connect(), disconnect(), ApnsPHP_Push_Server::onShutdown(), ApnsPHP_Push_Server::onSignal(), ApnsPHP_Feedback::receive(), ApnsPHP_Push::send(), and ApnsPHP_Push_Server::start().
void connect | ( | ) |
Connects to Apple Push Notification service server.
Retries ConnectRetryTimes if unable to connect and waits setConnectRetryInterval between each attempts.
ApnsPHP_Exception | if is unable to connect after ConnectRetryTimes. |
Definition at line 328 of file Abstract.php.
References _connect(), and _log().
Referenced by ApnsPHP_Push::_updateQueue().
boolean disconnect | ( | ) |
Disconnects from Apple Push Notifications service server.
Definition at line 356 of file Abstract.php.
References _log().
Referenced by ApnsPHP_Push::_updateQueue().
string getCertificateAuthority | ( | ) |
Get the Root Certification Authority file path.
Definition at line 185 of file Abstract.php.
References $_sRootCertificationAuthorityFile.
integer getConnectRetryInterval | ( | ) |
Get the connect retry interval.
Definition at line 280 of file Abstract.php.
References $_nConnectRetryInterval.
integer getConnectRetryTimes | ( | ) |
Get the connect retry time value.
Definition at line 255 of file Abstract.php.
References $_nConnectRetryTimes.
integer getConnectTimeout | ( | ) |
Get the connection timeout.
Definition at line 232 of file Abstract.php.
References $_nConnectTimeout.
ApnsPHP_Log_Interface getLogger | ( | ) |
Get the Logger instance.
Definition at line 139 of file Abstract.php.
References $_logger.
integer getSocketSelectTimeout | ( | ) |
Get the TCP socket select timeout.
Definition at line 312 of file Abstract.php.
References $_nSocketSelectTimeout.
integer getWriteInterval | ( | ) |
Get the write interval.
Definition at line 209 of file Abstract.php.
References $_nWriteInterval.
void setConnectRetryInterval | ( | integer | $nRetryInterval | ) |
Set the connect retry interval.
If the client is unable to connect to the server retries at least for ConnectRetryTimes and waits for this value between each attempts.
$nRetryInterval | Connect retry interval in micro seconds. |
Definition at line 270 of file Abstract.php.
void setConnectRetryTimes | ( | integer | $nRetryTimes | ) |
Set the connect retry times value.
If the client is unable to connect to the server retries at least for this value. The default connect retry times is 3.
$nRetryTimes | Connect retry times. |
Definition at line 245 of file Abstract.php.
void setConnectTimeout | ( | integer | $nTimeout | ) |
Set the connection timeout.
The default connection timeout is the PHP internal value "default_socket_timeout".
$nTimeout | Connection timeout in seconds. |
Definition at line 222 of file Abstract.php.
void setLogger | ( | ApnsPHP_Log_Interface | $logger | ) |
Set the Logger instance to use for logging purpose.
The default logger is ApnsPHP_Log_Embedded, an instance of ApnsPHP_Log_Interface that simply print to standard output log messages.
To set a custom logger you have to implement ApnsPHP_Log_Interface and use setLogger, otherwise standard logger will be used.
$logger | Logger instance. |
ApnsPHP_Exception | if Logger is not an instance of ApnsPHP_Log_Interface. |
Definition at line 118 of file Abstract.php.
void setProviderCertificatePassphrase | ( | string | $sProviderCertificatePassphrase | ) |
Set the Provider Certificate passphrase.
$sProviderCertificatePassphrase | Provider Certificate passphrase. |
Definition at line 150 of file Abstract.php.
void setRootCertificationAuthority | ( | string | $sRootCertificationAuthorityFile | ) |
Set the Root Certification Authority file.
Setting the Root Certification Authority file automatically set peer verification on connect.
$sRootCertificationAuthorityFile | Root Certification Authority file. |
ApnsPHP_Exception | if Root Certification Authority file is not readable. |
Definition at line 170 of file Abstract.php.
void setSocketSelectTimeout | ( | integer | $nSelectTimeout | ) |
Set the TCP socket select timeout.
After writing to socket waits for at least this value for read stream to change status.
In Apple Push Notification protocol there isn't a real-time feedback about the correctness of notifications pushed to the server; so after each write to server waits at least SocketSelectTimeout. If, during this time, the read stream change its status and socket received an end-of-file from the server the notification pushed to server was broken, the server has closed the connection and the client needs to reconnect.
$nSelectTimeout | Socket select timeout in micro seconds. |
Definition at line 302 of file Abstract.php.
void setWriteInterval | ( | integer | $nWriteInterval | ) |
Set the write interval.
After each socket write operation we are sleeping for this time interval. To speed up the sending operations, use Zero as parameter but some messages may be lost.
$nWriteInterval | Write interval in micro seconds. |
Definition at line 199 of file Abstract.php.
|
protected |
Container for service URLs environments.
Definition at line 51 of file Abstract.php.
|
protected |
SSL Socket.
Definition at line 68 of file Abstract.php.
|
protected |
|
protected |
Connect retry interval in micro seconds.
Definition at line 63 of file Abstract.php.
Referenced by getConnectRetryInterval().
|
protected |
Connect retry times.
Definition at line 56 of file Abstract.php.
Referenced by getConnectRetryTimes().
|
protected |
Connect timeout in seconds.
Definition at line 55 of file Abstract.php.
Referenced by getConnectTimeout().
|
protected |
|
protected |
Socket select timeout in micro seconds.
Definition at line 64 of file Abstract.php.
Referenced by getSocketSelectTimeout().
|
protected |
Write interval in micro seconds.
Definition at line 62 of file Abstract.php.
Referenced by getWriteInterval().
|
protected |
Provider certificate file with key (Bundled PEM).
Definition at line 58 of file Abstract.php.
|
protected |
Provider certificate passphrase.
Definition at line 59 of file Abstract.php.
|
protected |
Root certification authority file.
Definition at line 60 of file Abstract.php.
Referenced by getCertificateAuthority().
const CONNECT_RETRY_INTERVAL = 1000000 |
integer Default connect retry interval in micro seconds.
Definition at line 48 of file Abstract.php.
const DEVICE_BINARY_SIZE = 32 |
integer Device token length.
Definition at line 45 of file Abstract.php.
const ENVIRONMENT_PRODUCTION = 0 |
integer Production environment.
Definition at line 42 of file Abstract.php.
const ENVIRONMENT_SANDBOX = 1 |
integer Sandbox environment.
Definition at line 43 of file Abstract.php.
const SOCKET_SELECT_TIMEOUT = 1000000 |
integer Default socket select timeout in micro seconds.
Definition at line 49 of file Abstract.php.
const WRITE_INTERVAL = 10000 |
integer Default write interval in micro seconds.
Definition at line 47 of file Abstract.php.