Package com.google.appengine.api.channel

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


  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


          Long matchId = System.currentTimeMillis();
       
          DataOperation.newMatchTransaction(matchId, p1Email, p2Email, state, p2Email,new Date());
        
          channelService.sendMessage(new ChannelMessage(p1Email, "N,"+matchId));
          channelService.sendMessage(new ChannelMessage(p2Email, "N,"+matchId));
          return matchId;
     }
View Full Code Here

    public String AMove(String state, Long matchId, String id1, String id2){ 
    
         String turn= DataOperation.getTurnWithMatchId(matchId);
         turn = turn.equals(id1) ? id2 : id1;
         DataOperation.updateMatch(new Long(matchId), state, turn);
         channelService.sendMessage(new ChannelMessage(id2,"C,"+state));
         channelService.sendMessage(new ChannelMessage(id1,"C,"+state));     
         return state;
    }
View Full Code Here

    public String EndMove(String state, Long matchId, String id1, String id2, int meID){ 
    
         String turn= DataOperation.getTurnWithMatchId(matchId);
         turn = turn.equals(id1) ? id1 : id2;
         DataOperation.updateMatch(new Long(matchId), state, turn);
         channelService.sendMessage(new ChannelMessage(id2,"C,"+state));
         channelService.sendMessage(new ChannelMessage(id1,"C,"+state));
         Date currentDate = new Date();
         String currentDateString = DataOperation.dateToString(currentDate);
        
         String myRankAndRD = DataOperation.getRankAndRD(id1);
       String myRankString = myRankAndRD.split(" ")[0];
       String myRDString = myRankAndRD.split(" ")[1];
       int myRank = Integer.valueOf(myRankString);      
       int myRD = Integer.valueOf(myRDString);
             double myS;
            
             String oppRankAndRD = DataOperation.getRankAndRD(id2);
          String oppRankString = oppRankAndRD.split(" ")[0];
          String oppRDString = oppRankAndRD.split(" ")[1];
          int oppRank = Integer.valueOf(oppRankString);
          int oppRD = Integer.valueOf(oppRDString);
          double oppS;
         
          State st=StateSerializer.unserializeState(state);
             if(meID==0){
              if(st.getPlayers().get(0).getResult()==GameOver.Result.WIN){
                myS=1.0;
                if(st.getPlayers().get(1).getResult()==GameOver.Result.WIN)
                     oppS=1.0;
                else if(st.getPlayers().get(1).getResult()==GameOver.Result.LOSE)
                   oppS=0;
                else
                   oppS=0.5;
              }                
              else if(st.getPlayers().get(0).getResult()==GameOver.Result.LOSE){
                myS=0.0;
                  if(st.getPlayers().get(1).getResult()==GameOver.Result.WIN)
                       oppS=1.0;
                   else if(st.getPlayers().get(1).getResult()==GameOver.Result.LOSE)
                     oppS=0;
                   else
                     oppS=0.5;
               }else{
                  myS=0.5;
                  if(st.getPlayers().get(1).getResult()==GameOver.Result.WIN)
                       oppS=1.0;
                   else if(st.getPlayers().get(1).getResult()==GameOver.Result.LOSE)
                     oppS=0;
                   else
                     oppS=0.5;
               }
                  
             }else{
               if(st.getPlayers().get(1).getResult()==GameOver.Result.WIN){
                 myS=1.0;
                 if(st.getPlayers().get(0).getResult()==GameOver.Result.WIN)
                      oppS=1.0;
                 else if(st.getPlayers().get(0).getResult()==GameOver.Result.LOSE)
                    oppS=0;
                 else
                    oppS=0.5;
                }                
                else if(st.getPlayers().get(1).getResult()==GameOver.Result.LOSE){
                 myS=0.0;
                   if(st.getPlayers().get(0).getResult()==GameOver.Result.WIN)
                     oppS=1.0;
                else if(st.getPlayers().get(0).getResult()==GameOver.Result.LOSE)
                   oppS=0;
                else
                   oppS=0.5;
                 }else{
                   myS=0.5;
                   if(st.getPlayers().get(0).getResult()==GameOver.Result.WIN)
                        oppS=1.0;
                    else if(st.getPlayers().get(0).getResult()==GameOver.Result.LOSE)
                      oppS=0;
                    else
                      oppS=0.5;
                 }
             }
              
             String rankAndRD1=DataOperation.updateGamePeriodData(id1, currentDateString, myRD,(double) myRank, oppS);
             String rank1=rankAndRD1.split(" ")[0];
             String RD1=rankAndRD1.split(" ")[1];
             channelService.sendMessage(new ChannelMessage(id1,"R"+","+rank1+","+RD1));
             String rankAndRD2=DataOperation.updateGamePeriodData(id2, currentDateString,oppRD, (double) oppRank, myS);
             String rank2=rankAndRD2.split(" ")[0];
             String RD2=rankAndRD2.split(" ")[1];
             channelService.sendMessage(new ChannelMessage(id2,"R"+","+rank2+","+RD2));
         return state;
    }
View Full Code Here

    List<ChannelConnection> activeChannels = ObjectifyUtil.ofy().load().type(ChannelConnection.class).filter("active", true).list();
    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);
    }
  }
View Full Code Here

    }
  }
 
  private static ChannelMessage createMessage(String id, MessageType type, String payload) {
    String typeOrdinal = type.ordinal() + ""; // Encode enum
    return new ChannelMessage(id, typeOrdinal + "|" + payload); // Append message type and delimiter
  }
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)));
  }
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()));
    }
   
  }
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)));   
  }
View Full Code Here

TOP

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

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.