Java源码示例:javapns.communication.exceptions.CommunicationException
示例1
private void initializeConnection() throws KeystoreException, CommunicationException {
AppleNotificationServer server = new AppleNotificationServerBasicImpl(
keystore, password, production);
pushManager.initializeConnection(server);
isConnected = true;
}
示例2
/**
* Sends an alert notification to a list of devices.
*
* @param alertMessage alert to be sent as a push notification
* @param deviceTokens the list of tokens for devices to which the notifications should be sent
* @return a list of pushed notifications that contain details on transmission results.
* @throws javapns.communication.exceptions.CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws javapns.communication.exceptions.KeystoreException thrown if an error occurs with using the certificate.
*/
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
throws CommunicationException, KeystoreException {
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices started at " + dateFormat.format(new Date()) + ".");
PushedNotifications notifications =
sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices completed at " + dateFormat.format(new Date()) + ".");
return notifications;
}
示例3
private void initializeConnection() throws KeystoreException, CommunicationException {
AppleNotificationServer server = new AppleNotificationServerBasicImpl(
keystore, password, production);
pushManager.initializeConnection(server);
isConnected = true;
}
示例4
/**
* Sends an alert notification to a list of devices.
*
* @param alertMessage alert to be sent as a push notification
* @param deviceTokens the list of tokens for devices to which the notifications should be sent
* @return a list of pushed notifications that contain details on transmission results.
* @throws CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws KeystoreException thrown if an error occurs with using the certificate.
*/
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
throws CommunicationException, KeystoreException {
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices started at " + dateFormat.format(new Date()) + ".");
PushedNotifications notifications =
sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices completed at " + dateFormat.format(new Date()) + ".");
return notifications;
}
示例5
/**
* Create a SSLSocket which will be used to send data to Apple
* @return the SSLSocket
* @throws KeystoreException
* @throws CommunicationException
*/
public SSLSocket getSSLSocket() throws KeystoreException, CommunicationException {
SSLSocketFactory socketFactory = getSSLSocketFactory();
logger.debug("Creating SSLSocket to " + getServerHost() + ":" + getServerPort());
try {
if (ProxyManager.isUsingProxy(server)) {
return tunnelThroughProxy(socketFactory);
} else {
return (SSLSocket) socketFactory.createSocket(getServerHost(), getServerPort());
}
} catch (Exception e) {
throw new CommunicationException("Communication exception: " + e, e);
}
}
示例6
private void initializeConnection() throws KeystoreException, CommunicationException {
AppleNotificationServer server =
new AppleNotificationServerBasicImpl(keystore, password, production);
pushManager.initializeConnection(server);
isConnected = true;
}
示例7
/**
* Sends an alert notification to a list of devices.
*
* @param alertMessage alert to be sent as a push notification
* @param deviceTokens the list of tokens for devices to which the notifications should be sent
* @return a list of pushed notifications that contain details on transmission results.
* @throws CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws KeystoreException thrown if an error occurs with using the certificate.
*/
public PushedNotifications sendAlert(String alertMessage, String[] deviceTokens)
throws CommunicationException, KeystoreException {
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices started at " + dateFormat.format(new Date()) + ".");
PushedNotifications notifications =
sendPayload(PushNotificationPayload.alert(alertMessage), deviceTokens);
log.info("Sending alert='" + alertMessage + "' to " + deviceTokens.length
+ " devices completed at " + dateFormat.format(new Date()) + ".");
return notifications;
}
示例8
/**
* Stop connection and closes the socket
*
* @throws javapns.communication.exceptions.CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws javapns.communication.exceptions.KeystoreException thrown if an error occurs with using the certificate.
*/
public void stopConnection() throws CommunicationException, KeystoreException {
pushManager.stopConnection();
isConnected = false;
}
示例9
/**
* Stop connection and closes the socket
*
* @throws CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws KeystoreException thrown if an error occurs with using the certificate.
*/
public void stopConnection() throws CommunicationException, KeystoreException {
pushManager.stopConnection();
isConnected = false;
}
示例10
/**
* Stop connection and closes the socket
*
* @throws CommunicationException thrown if an error occurred while communicating with the target
* server even after a few retries.
* @throws KeystoreException thrown if an error occurs with using the certificate.
*/
public void stopConnection() throws CommunicationException, KeystoreException {
pushManager.stopConnection();
isConnected = false;
}