• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CommunicationException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javapns.communication.exceptions.CommunicationException的典型用法代码示例。如果您正苦于以下问题:Java CommunicationException类的具体用法?Java CommunicationException怎么用?Java CommunicationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommunicationException类属于javapns.communication.exceptions包,在下文中一共展示了CommunicationException类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
    }
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:27,代码来源:ApnsFacade.java


示例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);
    }
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:21,代码来源:ApnsFacade.java


示例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;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:15,代码来源:PushNotificationSender.java


示例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;
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:8,代码来源:Sender.java


示例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;
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:24,代码来源:Sender.java


示例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;
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-backend-starter-java,代码行数:24,代码来源:Sender.java


示例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);
	}
}
 
开发者ID:fernandospr,项目名称:javapns-jdk16,代码行数:21,代码来源:ConnectionToAppleServer.java


示例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;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:15,代码来源:PushNotificationSender.java


示例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;
}
 
开发者ID:googlesamples,项目名称:io2014-codelabs,代码行数:12,代码来源:Sender.java


示例16: 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;
}
 
开发者ID:googlearchive,项目名称:solutions-mobile-backend-starter-java,代码行数:12,代码来源:Sender.java



注:本文中的javapns.communication.exceptions.CommunicationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CameraManager类代码示例发布时间:2022-05-22
下一篇:
Java AbstractProjectViewPane类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap