本文整理汇总了Java中javapns.communication.exceptions.CommunicationException类的典型用法代码示例。如果您正苦于以下问题:Java CommunicationException类的具体用法?Java CommunicationException怎么用?Java CommunicationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommunicationException类属于javapns.communication.exceptions包,在下文中一共展示了CommunicationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
public IosResponse send(Payload payload, File certificado, String keyFile,
Boolean productionMode, List<String> devices) throws BusinessException {
try {
LOGGER.info("Enviando notificacion IOS");
PushedNotifications result;
String threads = parametroDao.getByName("IOS_THREADS").getValor();
if (threads != null && devices.size() >= Integer.parseInt(threads)) {
result = Push.payload(payload, certificado,
keyFile, productionMode, Integer.parseInt(threads), devices);
} else {
result = Push.payload(payload, certificado,
keyFile, productionMode, devices);
}
LOGGER.info("Procesando response: " + result.toString());
return procesarResponse(result);
} catch (CommunicationException e) {
LOGGER.error("CommunicationException" + e.getMessage());
throw new BusinessException(GlobalCodes.errors.IOS_COMM, e);
} catch (KeystoreException e1) {
LOGGER.error("KeystoreException" + e1.getMessage());
throw new BusinessException(GlobalCodes.errors.IOS_KEY_STORE, e1);
} catch (Exception ex) {
LOGGER.error("Exception" + ex.getMessage());
throw new BusinessException(GlobalCodes.errors.IOS_PUSH_PAYLOAD, ex);
}
}
示例2: doPost
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
long invitationId = Long.parseLong(req.getParameter("InvitationId"));
long gameId = Long.parseLong(req.getParameter("GameId"));
String messageText = req.getParameter("MessageText");
InvitationService service = new InvitationService();
try {
service.sendInvitationNotification(invitationId, gameId, messageText);
} catch (CommunicationException e) {
// Rethrow the exception so the request can be retried by the push queue.
throw new ServletException(e.getMessage());
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:17,代码来源:InvitationNotificationServlet.java
示例3: sendIosInvitationNotification
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* Sends an invitation notification to iOS devices.
*
* @param iOsDevices the list of Android devices to send the notification to.
* @param invitee the Player who has been invited.
* @param invitationId the invitation id.
* @param gameId the game id.
* @param messageText invitationText to be sent.
* @throws CommunicationException if an error occurred while sending iOS push notifications.
*/
private void sendIosInvitationNotification(List<DeviceEntity> iOsDevices, PlayerEntity invitee,
long invitationId, long gameId, String messageText) throws CommunicationException {
PushNotificationPayload payload = PushNotificationPayload.complex();
try {
payload.addAlert(messageText);
payload.addCustomDictionary("invitationId", String.valueOf(invitationId));
payload.addCustomDictionary("gameId", String.valueOf(gameId));
payload.addCustomDictionary("playerId", String.valueOf(invitee.getId()));
payload.addCustomDictionary("nickName", invitee.getNickname());
IosNotificationService notificationService = new IosNotificationService();
notificationService.sendPushNotification(iOsDevices, payload, invitee.getKey());
} catch (JSONException e) {
logger.log(Level.WARNING, "Invalid format of a push notification payload", e);
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:28,代码来源:InvitationService.java
示例4: getInactiveDevices
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
*
* @param certificado
* @param keyFile
* @param productionMode
* @return
* @throws BusinessException
*/
public List<Device> getInactiveDevices(File certificado, String keyFile,
Boolean productionMode) throws BusinessException {
try {
List<Device> lista;
lista = (List) Push.feedback(certificado, keyFile, productionMode);
return lista;
} catch (CommunicationException e) {
throw new BusinessException(GlobalCodes.errors.IOS_COMM, e);
} catch (KeystoreException e1) {
throw new BusinessException(GlobalCodes.errors.IOS_KEY_STORE, e1);
}
}
示例5: initializeConnection
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
private boolean initializeConnection() throws KeystoreException,
CommunicationException {
if (keystore != null) {
AppleNotificationServer server = new AppleNotificationServerBasicImpl(
keystore, PASSWORD, PRODUCTION);
pushManager.initializeConnection(server);
isConnected = true;
} else {
isConnected = false;
}
return isConnected;
}
示例6: initializeConnection
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
private void initializeConnection() throws KeystoreException, CommunicationException {
AppleNotificationServer server = new AppleNotificationServerBasicImpl(
keystore, password, production);
pushManager.initializeConnection(server);
isConnected = true;
}
示例7: sendAlert
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* 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;
}
示例8: sendAlert
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* 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;
}
示例9: doGet
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
IosNotificationService service = new IosNotificationService();
try {
service.processNotificationFeedback();
} catch (CommunicationException e) {
logger.log(Level.INFO, "CommunicationException when processing notification feedback.");
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:12,代码来源:NotificationFeedbackServlet.java
示例10: getSSLSocket
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* 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);
}
}
示例11: initializeConnection
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
private void initializeConnection() throws KeystoreException, CommunicationException {
AppleNotificationServer server =
new AppleNotificationServerBasicImpl(keystore, password, production);
pushManager.initializeConnection(server);
isConnected = true;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:8,代码来源:PushNotificationSender.java
示例12: sendAlert
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* 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;
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-ios-push-notification-sample-backend-java,代码行数:24,代码来源:PushNotificationSender.java
示例13: sendInvitationNotification
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* Sends an invitation notification to all devices registered for the invitee.
*
* @param invitationId the invitation id.
* @param gameId the game id.
* @throws CommunicationException when an error occurred when sending iOS push notifications.
* @throws IOException when an error occurred when sending Android push notifications.
*/
public void sendInvitationNotification(long invitationId, long gameId, String messageText)
throws IOException, CommunicationException {
InvitationEntity invitation = get(gameId, invitationId);
if (invitation == null) {
logger.log(Level.WARNING, "Invitation with invitationId=" + invitationId + " and gameId="
+ gameId + " not found. Ignoring sending notifications for this invitation.");
return;
}
PlayerService playerService = new PlayerService();
PlayerEntity invitee = playerService.get(invitation.getInviteeKey());
if (invitee == null) {
logger.log(Level.WARNING, "Invitee for the invitation with invitationId=" + invitationId
+ " and gameId=" + gameId
+ " not found. Ignoring sending notifications for this invitation.");
return;
}
List<DeviceEntity> devices = new DeviceService().getDevicesForPlayer(invitee.getKey());
List<DeviceEntity> iOsDevices = new ArrayList<DeviceEntity>();
List<DeviceEntity> androidDevices = new ArrayList<DeviceEntity>();
for (DeviceEntity device : devices) {
switch (device.getDeviceType()) {
case DeviceEntity.DEVICE_TYPE_ANDROID:
androidDevices.add(device);
break;
case DeviceEntity.DEVICE_TYPE_IOS:
iOsDevices.add(device);
break;
}
}
if (androidDevices.size() > 0) {
sendAndroidInvitationNotification(androidDevices, invitee, invitationId, gameId, messageText);
}
if (iOsDevices.size() > 0) {
sendIosInvitationNotification(iOsDevices, invitee, invitationId, gameId, messageText);
}
}
开发者ID:GoogleCloudPlatform,项目名称:solutions-griddler-sample-backend-java,代码行数:53,代码来源:InvitationService.java
示例14: stopConnection
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* 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;
}
示例15: stopConnection
import javapns.communication.exceptions.CommunicationException; //导入依赖的package包/类
/**
* 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;
}