Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

HTML5 client - no event for removed object

Developers
2012-01-27
2013-06-06
  • Zlatan Momic
    Zlatan Momic
    2012-01-27

    Removing multiple objects (tokens) at server side by calling zone.remove(token.getID()), I received notification only for first one deleted, inside onDeleted event at client side inside .

    This is startGame method for TicToe game. It removes old tokens when starting new game.

        protected void startGame() {
        // get gameboard/tokens zone
            final IRPZone zone = getZone();
            if (zone == null) {
                return;
            }
    
            // clear board state
            for (int xIndex = 0; xIndex < board.length; xIndex++) {
                for (int yIndex = 0; yIndex < board[xIndex].length; yIndex++) {
                    final Token token = board[xIndex][yIndex];
                    if (token != null) {
                        zone.remove(token.getID());
                    }
                    board[xIndex][yIndex] = null;
                }
            }
            
            // start new game
            active = true;        
        }
    

    Notification arrives but only for first token. So just first one is removed.

    marauroa.perceptionListener.onDeleted = function(object) {
        if ((object.hasOwnProperty("c")) && (object.hasOwnProperty("a"))) {
            switch (object.c) {
                case "token":
                    var ID = object.a.id;
                    $('#' + ID).remove();               
                    break;
            }
        }
    }
    
     
  • Thanks for the report, I fixed the function applyPerceptionDeletedRPObjects which was confusing index and id.

    Please note that perceptionListener.onDeleted needs to return false for the processing to  continue.

     


Anonymous


Cancel   Add attachments