Package com.google.appengine.api.channel

Examples of com.google.appengine.api.channel.ChannelService.sendMessage()


  public void onMessage(Message message) {
    parseMessage(message);
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    for (PageEntity page : getDao().getPageDao().select()) {
      if (filter(page)) {
        channelService.sendMessage(new ChannelMessage(
            clientId, createHitJSON(page)));
      }
    }
    channelService.sendMessage(new ChannelMessage(clientId, "({end:true})"));
  }
View Full Code Here


      if (filter(page)) {
        channelService.sendMessage(new ChannelMessage(
            clientId, createHitJSON(page)));
      }
    }
    channelService.sendMessage(new ChannelMessage(clientId, "({end:true})"));
  }

  private String createHitJSON(PageEntity page) {
    List<ContentEntity> contents = getDao().getPageDao().getContents(
        page.getId());
View Full Code Here

    for (ChannelConnection channel : activeChannels) {
      String clientId = channel.getClientId();
      // Payloads are not logged
      log.info("Sending message to " + clientId + " of type " + type);
      ChannelMessage msg = createMessage(clientId, type, payload);
      channelService.sendMessage(msg);
    }
  }
 
  private static ChannelMessage createMessage(String id, MessageType type, String payload) {
    String typeOrdinal = type.ordinal() + ""; // Encode enum
View Full Code Here

   * @param message the message to send
   */
  public void messageClient(String channelKey, Message message) {
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    System.out.println("Server " + channelKey + ": " + message + ".");
    channelService.sendMessage(new ChannelMessage(channelKey, pushServer.encodeMessage(message)));
  }

  public void messageClients(ArrayList<String> ids, Message message) {
    for (String id : ids)
      messageClient(id, message);
View Full Code Here

      System.out.println("neexistujici hra");
      return "zprava";
    }
    System.out.println(json.toString());
    for (Hrac s : tmp.getHraci().values()) {
      channel.sendMessage(new ChannelMessage(s.getUserId(), json.toString()));
    }
    return "zprava";
  }
 
 
View Full Code Here

    zprava.put("cil", cil);
   
    JSONObject json=JSONObject.fromObject(zprava);
    String z = toUTF8(json.toString());
    for (Hrac h : hra.getHraci().values()) {
      chanel.sendMessage(new ChannelMessage(h.getUserId(), json.toString()));
    }
   
  }
 
  public static void odesliHraci(Hrac hrac,String zprava){
View Full Code Here

  }
 
  public static void odesliHraci(Hrac hrac,String zprava){
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
   
    chanel.sendMessage(new ChannelMessage(hrac.getUserId(), toUTF8(zprava)));   
  }
 
  /**
   * Odesle zpravu, ktera je urcena pro vypis do chatu
   * @param hra
View Full Code Here

    zprava.put("text", textZpravy);
   
    JSONObject json=JSONObject.fromObject(zprava);
 
    for (Hrac s : hra.getHraci().values()) {
      chanel.sendMessage(new ChannelMessage(s.getUserId(), json.toString()));
    }
  }
 
  /**
   * Odesle zpravu vsem hracum ve hre
View Full Code Here

  public static void odesliVsem(Hra hra,String JSONtextZpravy){
    final ChannelService chanel = ChannelServiceFactory.getChannelService();

 
    for (Hrac s : hra.getHraci().values()) {
      chanel.sendMessage(new ChannelMessage(s.getUserId(), JSONtextZpravy));
    }
  }
 
  public static void odesliHrace(String hraId, String login, String userId) {
   
View Full Code Here

   
    JSONObject json=JSONObject.fromObject(zprava);

    for (Hrac s : tmp.getHraci().values()) {
      if (!userId.equals(s.getUserId()))
        chanel.sendMessage(new ChannelMessage(s.getUserId(), json.toString()));
    }
  }

  public static void odesliSeznamHracu(String hraId, String userId) {
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.