Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
Adding some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pimotte committed Aug 2, 2014
1 parent 14471c1 commit f5d24ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -21,6 +21,8 @@
import io.undertow.server.HttpServerExchange;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.syncany.plugins.Plugins;
import org.syncany.plugins.web.WebInterfacePlugin;
Expand All @@ -30,6 +32,7 @@
*
*/
public class InternalWebInterfaceHandler implements HttpHandler {
private static final Logger logger = Logger.getLogger(InternalWebInterfaceHandler.class.getSimpleName());
private List<WebInterfacePlugin> webInterfacePlugins;
private WebInterfacePlugin webInterfacePlugin;
private HttpHandler requestHandler;
Expand All @@ -47,6 +50,7 @@ private void initWebInterfacePlugin() {
webInterfacePlugin = webInterfacePlugins.iterator().next();
requestHandler = webInterfacePlugin.createRequestHandler();

logger.log(Level.INFO, "Starting webInterfacePlugin: " + webInterfacePlugin.getId());
webInterfacePlugin.start();
}
catch (Exception e) {
Expand All @@ -65,6 +69,7 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
}

private void handleRequestWithResourceHandler(HttpServerExchange exchange) throws Exception {
logger.log(Level.FINE, "Sending request to webInterfacePlugin handler: " + exchange.toString());
requestHandler.handleRequest(exchange);
}

Expand Down
Expand Up @@ -48,10 +48,12 @@ public class InternalWebSocketHandler implements WebSocketConnectionCallback {
public InternalWebSocketHandler(DaemonWebServer daemonWebServer) {
this.daemonWebServer = daemonWebServer;
eventBus = DaemonEventBus.getInstance();
eventBus.register(this);
}

@Override
public void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel) {
logger.log(Level.INFO, "Connecting to websocket server.");
// Validate origin header (security!)
String originHeader = exchange.getRequestHeader("Origin");
boolean allowedOriginHeader = (originHeader == null ||
Expand All @@ -62,6 +64,8 @@ public void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel)
exchange.close();
}
else {
logger.log(Level.INFO, "Valid origin header, setting up connection.");

channel.getReceiveSetter().set(new AbstractReceiveListener() {
@Override
protected void onFullTextMessage(WebSocketChannel clientChannel, BufferedTextMessage message) {
Expand Down

0 comments on commit f5d24ff

Please sign in to comment.