Skip to content

Commit

Permalink
Merge pull request #3 from tenowg/master
Browse files Browse the repository at this point in the history
Timer to Executor... maybe imports are right now.
  • Loading branch information
Luke Spragg committed Aug 8, 2013
2 parents d7fc672 + 0bf4c3d commit 487a2ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
package org.spout.aquaduct;

import java.io.File;

import org.spout.cereal.config.ConfigurationException;
import org.spout.cereal.config.ConfigurationHolder;
import org.spout.cereal.config.ConfigurationHolderConfiguration;
import org.spout.cereal.config.yaml.YamlConfiguration;


public class AquaductConfiguration extends ConfigurationHolderConfiguration {
public static ConfigurationHolder BIND_ADDRESS = new ConfigurationHolder((Object) null, "bind.address");
public static ConfigurationHolder BIND_PORT = new ConfigurationHolder(80, "bind.port");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
package org.spout.aquaduct.web;

import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;

import com.google.gson.Gson;
import com.google.gson.JsonElement;
Expand All @@ -36,26 +36,27 @@
import com.narrowtux.blueberry.websockets.WebSocketExchange;
import com.narrowtux.blueberry.websockets.WebSocketRequestHandler;


public class AquaductWebSocketHandler extends WebSocketRequestHandler {
private HashSet<WebSocketExchange> connectedClients = new HashSet<WebSocketExchange>();
private static final Gson GSON = new Gson();
private HashMap<String, WebClientRequestHandler> requestHandlers = new HashMap<String, WebClientRequestHandler>();

private int countup = 1;
private Timer timer = new Timer();
private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

public AquaductWebSocketHandler() {
super();
setFilter("/websocket/");

timer.schedule(new TimerTask() {
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
countup ++;
WebClientFrame event = new WebClientEvent("counter", countup);
sendEvent(event);
}
}, 100, 1000);
}, 100, 1000, TimeUnit.MILLISECONDS);
}

public void sendEvent(WebClientFrame event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public class ResourceFileHandler extends HttpRequestHandler {
private static int BUFFER_SIZE = 512;
private static String BASE_PATH = "src/main/resources/"; // TODO configuration
private static MimetypesFileTypeMap MIMETYPES = new MimetypesFileTypeMap();
private static final MimetypesFileTypeMap MIMETYPES = new MimetypesFileTypeMap();

static {
MIMETYPES.addMimeTypes("application/javascript js JS");
Expand Down

0 comments on commit 487a2ee

Please sign in to comment.