/** Process delayed direction release. */ synchronized void processDelayedDirectionRelease() { if ((directionRelease != null) && directionRelease.hasExpired()) { client.removeDirection(directionRelease.getDirection(), directionRelease.isFacing()); directionRelease = null; } }
/** * Handle direction release actions. * * @param direction The direction. * @param facing If facing only. */ private synchronized void processDirectionRelease( final Direction direction, final boolean facing) { if (directionRelease != null) { if (directionRelease.check(direction, facing)) { /* * Ignore repeats */ return; } else { /* * Flush previous release */ client.removeDirection(directionRelease.getDirection(), directionRelease.isFacing()); } } directionRelease = new DelayedDirectionRelease(direction, facing); }
/** * Handle direction press actions. * * @param direction The direction. * @param facing If facing only. */ private synchronized void processDirectionPress(final Direction direction, final boolean facing) { if (directionRelease != null) { if (directionRelease.check(direction, facing)) { directionRelease = null; return; } else { /* * Flush pending release */ client.removeDirection(directionRelease.getDirection(), directionRelease.isFacing()); directionRelease = null; } } if (client.addDirection(direction, facing)) { // Movement prediction. User user = User.get(); if (user != null) { user.predictMovement(direction, facing); } } }