Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.errai.demo.mobile.server;
 
 import java.util.List;
 import java.util.Map;
Acts like a communications satellite in orbit over the attached clients: receives the stream of orientation events from all attached clients, aggregates them, and relays them back to the clients.

Author(s):
Jonathan Fuerth <jfuerth@gmail.com>
public class OrientationDataSatellite {
  }
  public void startRedistributionService() {
    executor.scheduleWithFixedDelay(new Runnable() {
      @Override
      public void run() {
        // TODO remove clients who have not sent an update for a while
        List<OrientationEventclientOrientationList =
            new ArrayList<OrientationEvent>(.values());
        .fire(new AllClientOrientations(clientOrientationList));
        long cutoffTime = System.currentTimeMillis() - 2000;
        while (it.hasNext()) {
          Map.Entry<StringOrientationEvententry = it.next();
          if (entry.getValue().getTimestamp() < cutoffTime) {
            it.remove();
            .fire(entry.getValue());
          }
        }
      }
    }, 1000, 250, .);
  }
New to GrepCode? Check out our FAQ X