Package com.google.appengine.api.channel

Examples of com.google.appengine.api.channel.ChannelService


    }
   
  }
 
  public static void odesliHraci(Hrac hrac,String zprava){
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
   
    chanel.sendMessage(new ChannelMessage(hrac.getUserId(), toUTF8(zprava)));   
  }
View Full Code Here


   * Odesle zpravu, ktera je urcena pro vypis do chatu
   * @param hra
   * @param textZpravy
   */
  public static void odesliVsem(Hra hra,String typ,String textZpravy){
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
   
    HashMap<String, String> zprava=new HashMap<String, String>();
   
    zprava.put("typ", typ);
    zprava.put("text", textZpravy);
   
    JSONObject json=JSONObject.fromObject(zprava);
 
    for (Hrac s : hra.getHraci().values()) {
      chanel.sendMessage(new ChannelMessage(s.getUserId(), json.toString()));
    }
  }
View Full Code Here

   * Odesle zpravu vsem hracum ve hre
   * @param hra
   * @param textZpravy
   */
  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));
    }
  }
View Full Code Here

    }
  }
 
  public static void odesliHrace(String hraId, String login, String userId) {
   
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
    Hra tmp = SpravceHer.getInstance().getHra(hraId);
   
    HashMap<String, String> zprava=new HashMap<String, String>();
   
    zprava.put("typ", "connect");
    zprava.put("login", login);
   
    JSONObject json=JSONObject.fromObject(zprava);

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

  }

  public static void odesliSeznamHracu(String hraId, String userId) {
   
    System.out.println("odeslani seznamu hracu");
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
    Hra tmp = SpravceHer.getInstance().getHra(hraId);
   
    for (Hrac s : tmp.getHraci().values()) {
     
      HashMap<String, String> zprava=new HashMap<String, String>();
      zprava.put("typ", "connect");
      zprava.put("login", s.getNick());
     
      JSONObject json=JSONObject.fromObject(zprava);

      chanel.sendMessage(new ChannelMessage(userId, json.toString()));
     
      System.out.println("odelslano" + userId);
    }
  }
View Full Code Here

   * @param hra
   * @param hrac
   * @param zprava
   */
  public static void odesliHraciZpravu(Hrac hrac, String zprava){
    final ChannelService chanel = ChannelServiceFactory.getChannelService();
    HashMap<String, String> jsonMap=new HashMap<String, String>();
    jsonMap.put("typ", "chatInfo");
    jsonMap.put("text",zprava);
    JSONObject json=JSONObject.fromObject(jsonMap);
   
    chanel.sendMessage(new ChannelMessage(hrac.getUserId(), toUTF8(json.toString())));     
  }
View Full Code Here

    model.addAttribute("login", Zpravy.upravText(login));
    model.addAttribute("user", Zpravy.upravText(userId));
   
    //vytvoreni tokenu
    //asi vytvoreni kanalu a prirazeni tokenu
    final ChannelService channelService = ChannelServiceFactory.getChannelService();
    if (channelService != null){
       token = channelService.createChannel(userId);
       zakladatel.setChannel(token);
       model.addAttribute("usrKey", Zpravy.upravText(token));
   
   
View Full Code Here

  }
 
  @RequestMapping("/pripoj.se")
  public String vychozi(Model model, @RequestParam("hra") String hraId){
    //prihlaseni hrace
    final ChannelService channelService = ChannelServiceFactory.getChannelService();
    final UserService userService = UserServiceFactory.getUserService();
    String userId;
    String login;
    String token;
   
    if(!userService.isUserLoggedIn()){
      model.addAttribute("link", userService.createLoginURL("/pripoj.se?hra="+hraId));
      return "login";
    }
   
    else {
      //uzivatel je prihlasen
      if(userService != null) {
         userId = userService.getCurrentUser().getUserId();
         login = userService.getCurrentUser().getNickname();
         model.addAttribute("userId", Zpravy.upravText(userId));
         model.addAttribute("login", Zpravy.upravText(login));
        
         Hrac pripojeny=new Hrac(userId,login);
        
         SpravceHer.getInstance().getHra(hraId).addHrac(userId, pripojeny);
         SeznamHracu sh = SpravceHer.getInstance().getHra(hraId).getHraci();
         System.out.println(sh.vratPocetHracu());
         //vytvoreni tokenu
         //asi vytvoreni kanalu a prirazeni tokenu
         if (channelService != null){
           token = channelService.createChannel(userId);
           pripojeny.setChannel(token);
          
           model.addAttribute("usrKey", Zpravy.upravText(token));
           model.addAttribute("hraId", Zpravy.upravText(hraId));
           model.addAttribute("user", Zpravy.upravText(userId));
View Full Code Here

  }
 
  @Override
  public void manage(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    ChannelPresence presence = channelService.parsePresence(req);
    String email = presence.clientId();
    UserBeanOAM oam = provider.get();
    oam.updateOnline(isOnline(), email);
    GetUserInfoResult result = oam.getGetUserInfoResult(email);
    for(String online : result.getOnline()){
      log.info(email+" is online = "+isOnline()+". Sending message to "+online);
      channelService.sendMessage(new ChannelMessage(online, getJson(email, online)));
    }
  }
View Full Code Here

  public SendMessageResult execute(@Valid SendMessage action,
      ExecutionContext context) throws ActionException {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    String json = toJson.getJson(action.getMessage(), user.getEmail(), MessageType.message);
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    channelService.sendMessage(new ChannelMessage(action.getEmail(), json));
    MessageOAM oam = provider.get();
    oam.addMessage(action, user.getEmail());
    return new SendMessageResult();
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.channel.ChannelService

Copyright © 2018 www.massapicom. 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.