Package com.google.appengine.api.channel

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


    str += "]";
   
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    for(int n = 0; n < this.arrNetNodesIds.size(); n++) {   
      String channelKey = getChannelKey(this.arrNetNodesIds.get(n));
      channelService.sendMessage(new ChannelMessage(channelKey, str));
    }
  }
View Full Code Here


    str += "]";
   
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    for(int n = 0; n < this.arrNetNodesIds.size(); n++) {
      String channelKey = getChannelKey(this.arrNetNodesIds.get(n));
      channelService.sendMessage(new ChannelMessage(channelKey, str));
    }
   
    int idxToDel = 0;
    for(int n = 0; n < this.arrNetNodesIds.size(); n++) {  
      if(this.arrNetNodesIds.get(n).equals(userID)) {
View Full Code Here

     *
     * @param clientId the client ID
     * @param message the message to send
     */
    public static void send(ChannelService channel, String clientId, String message) {
        channel.sendMessage(new ChannelMessage(clientId, message));
    }
View Full Code Here

   
    while(keys.hasMoreElements()){
      key = keys.nextElement();
      if( key.equals("123321")) continue;
      try{
        channelService.sendMessage(new ChannelMessage(key, message));
        channelService.sendMessage(new ChannelMessage(key, gsu));
      }catch(Exception e){
        e.printStackTrace();
      }
    }   
  }
View Full Code Here

        userId = req.getParameter(Constant.USER_ID).toString();
        if(userMap.get(userId) == null)
          break;
        String ngToken = String.valueOf(UUID.randomUUID().getMostSignificantBits());
          channelService = ChannelServiceFactory.getChannelService();
          channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.NEW_GAME_TOKEN+"\"}"));
          channelService.sendMessage(new ChannelMessage(userId, gson.toJson(ngToken)))
          gameTokenList.put(ngToken, userId);
          break;
      case Constant.NEW_GAME:
        cBrd = CheckerModel.checkerBoard();
        r = gson.toJson(cBrd);
        break;
      case Constant.PLAY:
        cBrd = gson.fromJson(req.getParameter("cBoard[][]").toString(), char[][].class);
        turn = gson.fromJson(req.getParameter("player").toString(), char.class);
       
        Position[][] mt = MoveTable.moveTable(cBrd, turn);
       
        r = gson.toJson(mt);
        break;
      case Constant.NEW_TOKEN:
        userId = req.getParameter(Constant.USER_ID).toString();
        userName = req.getParameter(Constant.USER_NAME).toString();
        User user = new User(userId, userName);
        inSignIn.put(userId, user);
        //XXXXXXXXXXXTest if user exist xxxxxxxxxxxxxxxxxxxxxxx
          channelService = ChannelServiceFactory.getChannelService();
          String token = channelService.createChannel(userId);
          r = token;
          break;
      case Constant.CONNECTED_USER_LIST:
        userId = req.getParameter(Constant.USER_ID).toString();
        if( userMap.get(userId) != null){
              channelService = ChannelServiceFactory.getChannelService();
              channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.CONNECTED_USER_LIST+"\"}"));
              channelService.sendMessage(new ChannelMessage(userId, gson.toJson(userMap)));
        }else
          r = "You are not connected!!!";
        break;
    }   
    resp.getWriter().print(r)
View Full Code Here

       
        if( gm != null && gm.move(mtr, piece) == true){
          rId = gm.getUserId(userId);
          Checkers.log.info("++++++++++++GAME_MOVE    Sending Move to remote host id "+rId+"++++++++++++");
          channelService = ChannelServiceFactory.getChannelService();
          channelService.sendMessage(new ChannelMessage(rId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_MOVE+"\"}"));
            channelService.sendMessage(new ChannelMessage(rId, gson.toJson(mtr)));   
           
            if( gm.getMTable() == null ){
              channelService.sendMessage(new ChannelMessage(rId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_PLAY+"\"}"));
              channelService.sendMessage(new ChannelMessage(rId, gson.toJson(Constant.GAME_PLAY)));               
            }
           
        }else
          Checkers.log.info("++++++++++++GAME_MOVE  game not "+gm+" OR invalid move for token "+tk+" AND mtr "+mtr+" ++++++++++++");
       
        break
      case Constant.GAME_MTABLE:
        userId = req.getParameter(Constant.USER_ID).toString();
        tk = req.getParameter(Constant.GAME_TOKEN).toString();
        piece = req.getParameter(Constant.GAME_PIECE).toString().charAt(0);
        gm = gameMap.get(tk)
       
        if( gm != null ){
          Position[][] mt = gm.getMTable(piece);
         
          channelService = ChannelServiceFactory.getChannelService();
          channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_MTABLE+"\"}"));
            channelService.sendMessage(new ChannelMessage(userId, gson.toJson(mt)));           
        }
       
        break;
      case Constant.JOIN_GAME :
        userId = req.getParameter(Constant.USER_ID).toString();
        tk = req.getParameter(Constant.GAME_TOKEN).toString();
        rId = Checkers.gameTokenList.get(tk);
       
        channelService = ChannelServiceFactory.getChannelService();
        if( rId != null && Checkers.userMap.get(rId) != null /*&& playerMap.get(rId) == null && playerMap.get(userId)== null */){ 
         
          Checkers.gameTokenList.remove(tk);
          Checkers.playerMap.put(userId, Checkers.userMap.get(userId));
          Checkers.playerMap.put(rId, Checkers.userMap.get(rId));
         
          gm = new Game(userId, rId);
          gameMap.put(tk, gm);
         
          //----USER 1
          channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.JOIN_GAME+"\"}"));
            channelService.sendMessage(new ChannelMessage(userId, gson.toJson(Checkers.userMap.get(rId))));           
          channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_BOARD+"\"}"));
            channelService.sendMessage(new ChannelMessage(userId, gson.toJson(gm.getCBoard())))
          channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_PIECE+"\"}"));
            channelService.sendMessage(new ChannelMessage(userId, gson.toJson(gm.getTurn())))
           
            channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_PLAY+"\"}"));
            channelService.sendMessage(new ChannelMessage(userId, gson.toJson(Constant.GAME_PLAY)))
           
           
            //----USER 2
            channelService.sendMessage(new ChannelMessage(rId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.JOIN_GAME+"\"}"));
            channelService.sendMessage(new ChannelMessage(rId, gson.toJson(Checkers.userMap.get(userId))));  
          channelService.sendMessage(new ChannelMessage(rId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_BOARD+"\"}"));
            channelService.sendMessage(new ChannelMessage(rId, gson.toJson(gm.getCBoard())))
          channelService.sendMessage(new ChannelMessage(rId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_PIECE+"\"}"));
            channelService.sendMessage(new ChannelMessage(rId, gson.toJson(gm.getRTurn())))
        }else{
            channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.GAME_JOINING_FAILED+"\"}"));
            channelService.sendMessage(new ChannelMessage(userId, gson.toJson(tk)))
        }
        break;
    }
    resp.getWriter().print(r);
  }
View Full Code Here

     
      while(keys.hasMoreElements()){
        key = keys.nextElement();
        if( key.equals("123321")) continue;
        try{
          channelService.sendMessage(new ChannelMessage(key, message));
          channelService.sendMessage(new ChannelMessage(key, gsu));
        }catch(Exception e){
          e.printStackTrace();
        }
      }
      Checkers.inSignIn.remove(userId);
View Full Code Here

      String rId = msg.getrId();
     
      if( userId.equals(msg.getsId()) && Checkers.userMap.get(userId) != null && Checkers.userMap.get(rId) != null ){
        //---------ICI Tester la valider du message-------------
        ChannelService channelService = ChannelServiceFactory.getChannelService();
          channelService.sendMessage(new ChannelMessage(rId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.MESSAGE+"\"}"));
          channelService.sendMessage(new ChannelMessage(rId, gson.toJson(msg)));
      }else if(userId.equals(msg.getsId()) ){
        ChannelService channelService = ChannelServiceFactory.getChannelService();
          channelService.sendMessage(new ChannelMessage(userId, "{\""+Constant.MESSAGE_TYPE+"\":\""+Constant.ERROR+"\"}"));
          channelService.sendMessage(new ChannelMessage(userId, gson.toJson(new String("Code : "+Constant.ERR_CODEOO1+" Message has not been sent to : "+rId))));       
      }
     
    }
   
  }
View Full Code Here

    List<String> pathlist = Arrays.asList( path.split("/") ) ;
    Datastore datastore = new Datastore();
    Datastore.EntityWrap e = datastore.updateEntity(pathlist, input, meta);
   
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    channelService.sendMessage( new ChannelMessage("/" + path, "M" ) );
    channelService.sendMessage( new ChannelMessage(e.getParentPath()+"/", "M" ) );
       
   
    resp.setContentType("application/json");
    String msg = Utils.makeGson().toJson(entityToMap(e.entity,e.getParentPath()), Map.class );
    resp.getWriter().println(msg);
View Full Code Here

      while ((line = reader.readLine()) != null)
        jb.append(line);
    } catch (Exception e) { /*report an error*/ }

    ChannelService channelService = ChannelServiceFactory.getChannelService();
    channelService.sendMessage( new ChannelMessage(path, jb.toString() ) );
    resp.setContentType("text/plain");
    resp.getWriter().write("sent\n");

 
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.