@@ -0,0 +1,1527 @@
+package com.haxademic.core.net;%0A%0Aimport com.haxademic.core.app.P;%0Aimport com.haxademic.core.net.JSONUtil;%0Aimport com.haxademic.core.net.WebSocketRelay;%0A%0Aimport processing.data.JSONObject;%0A%0Apublic class WebSocketServer %7B%0A%0A%09protected SocketRelay _server;%0A%09%0A%09public WebSocketServer() %7B%0A%09%09// fire up websocket server%0A%09%09WebSocketRelay.DEBUG = false;%0A%09%09try %7B%0A%09%09%09_server = new SocketRelay();%0A%09%09%09_server.start();%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09P.println(%22Couldn't start Socket server!%22);%0A%09%09%7D%0A%09%7D%0A%09%0A%09public String hostName() %7B%0A%09%09return %22Server: ws://%22 + _server.localHost + %22:%22 + _server.portStr;%0A%09%7D%0A%09%0A%09///////////////////////%0A%09// websocket helpers%0A%09///////////////////////%0A%0A%09public void sendSocketMessage(String service, String command, String data) %7B%0A%09    JSONObject jsonOut = new JSONObject();%0A%09%09if(service != null) jsonOut.setString(%22service%22, service);%0A%09%09if(command != null) jsonOut.setString(%22command%22, command);%0A%09%09if(data != null)    jsonOut.setString(%22data%22, data);%0A%09    _server.sendMessage(JSONUtil.jsonToSingleLine(jsonOut));%0A%09%7D%0A%09%0A%09///////////////////////%0A%09// Override of WebSocketRelay to act as a socket client with server listeners%0A%09///////////////////////%0A%0A%09public class SocketRelay extends WebSocketRelay %7B%0A%09%09%0A%09%09protected void receiveMessage(String message) %7B%0A%09%09%09if(message.indexOf(%22kinect_alive%22) != -1) %7B%0A%09%09%09%09if(WebSocketRelay.DEBUG == true) P.println(%22receiveMessage%22, message);%0A%09%09%09%09if(WebSocketRelay.DEBUG == true) P.println(%22lastKinectPingTime = %22, P.p.millis());%0A//%09%09%09%09_lastKinectPingTime = p.millis();%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add WebSocketServer base class