Issue #3242 - Updating BrowserDebugTool to help troubleshoot issue
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
da3d69261c
commit
0078d8aed6
|
@ -18,14 +18,22 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server.browser;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.handler.ResourceHandler;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.PathResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.common.extensions.FrameCaptureExtension;
|
||||
import org.eclipse.jetty.websocket.server.WebSocketHandler;
|
||||
|
@ -120,8 +128,7 @@ public class BrowserDebugTool implements WebSocketCreator
|
|||
return connector.getLocalPort();
|
||||
}
|
||||
|
||||
public void prepare(int port)
|
||||
{
|
||||
public void prepare(int port) throws IOException, URISyntaxException {
|
||||
server = new Server();
|
||||
connector = new ServerConnector(server);
|
||||
connector.setPort(port);
|
||||
|
@ -150,16 +157,22 @@ public class BrowserDebugTool implements WebSocketCreator
|
|||
|
||||
server.setHandler(wsHandler);
|
||||
|
||||
String resourceBase = "src/test/resources/browser-debug-tool";
|
||||
Resource staticResourceBase = findStaticResources();
|
||||
|
||||
ResourceHandler rHandler = new ResourceHandler();
|
||||
rHandler.setDirectoriesListed(true);
|
||||
rHandler.setResourceBase(resourceBase);
|
||||
rHandler.setBaseResource(staticResourceBase);
|
||||
wsHandler.setHandler(rHandler);
|
||||
|
||||
LOG.info("{} setup on port {}",this.getClass().getName(),port);
|
||||
}
|
||||
|
||||
private Resource findStaticResources() throws FileNotFoundException, URISyntaxException, MalformedURLException {
|
||||
Path path = MavenTestingUtils.getTestResourcePathDir("browser-debug-tool");
|
||||
LOG.info("Static Resources: {}", path);
|
||||
return new PathResource(path);
|
||||
}
|
||||
|
||||
public void start() throws Exception
|
||||
{
|
||||
server.start();
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
|
|||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
||||
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketSession;
|
||||
|
||||
@WebSocket
|
||||
public class BrowserSocket
|
||||
|
@ -226,6 +227,11 @@ public class BrowserSocket
|
|||
writeMessage("Server time: %s",sdf.format(now.getTime()));
|
||||
break;
|
||||
}
|
||||
case "dump":
|
||||
{
|
||||
((WebSocketSession)session).dumpStdErr();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
writeMessage("key[%s] val[%s]",key,val);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<input id="manythreads" class="button" type="submit" name="many" value="manythreads" disabled="disabled"/>
|
||||
<input id="hello" class="button" type="submit" name="hello" value="hello" disabled="disabled"/>
|
||||
<input id="there" class="button" type="submit" name="there" value="there" disabled="disabled"/>
|
||||
<input id="dump" class="button" type="submit" name="dump" value="dump" disabled="disabled"/>
|
||||
<input id="json" class="button" type="submit" name="json" value="json" disabled="disabled"/>
|
||||
<input id="twain" class="button" type="submit" name="twain" value="twain" disabled="disabled"/>
|
||||
<input id="send10k" class="button" type="submit" name="send10k" value="send10k" disabled="disabled"/>
|
||||
<input id="send100k" class="button" type="submit" name="send100k" value="send100k" disabled="disabled"/>
|
||||
<input id="send1000k" class="button" type="submit" name="send1000k" value="send1000k" disabled="disabled"/>
|
||||
|
@ -32,7 +32,7 @@
|
|||
$("manythreads").onclick = function(event) {wstool.write("manythreads:20,25,60"); return false; }
|
||||
$("hello").onclick = function(event) {wstool.write("Hello"); return false; }
|
||||
$("there").onclick = function(event) {wstool.write("There"); return false; }
|
||||
$("twain").onclick = function(event) {wstool.write("@twain.txt"); return false; }
|
||||
$("dump").onclick = function(event) {wstool.write("dump:"); return false; }
|
||||
$("json").onclick = function(event) {wstool.write("[{\"channel\":\"/meta/subscribe\",\"subscription\":\"/chat/demo\",\"id\":\"2\",\"clientId\":\"81dwnxwbgs0h0bq8968b0a0gyl\",\"timestamp\":\"Thu,"
|
||||
+ " 12 Sep 2013 19:42:30 GMT\"},{\"channel\":\"/meta/subscribe\",\"subscription\":\"/members/demo\",\"id\":\"3\",\"clientId\":\"81dwnxwbgs0h0bq8968b0a0gyl\",\"timestamp\":\"Thu,"
|
||||
+ " 12 Sep 2013 19:42:30 GMT\"},{\"channel\":\"/chat/demo\",\"data\":{\"user\":\"ch\",\"membership\":\"join\",\"chat\":\"ch"
|
||||
|
|
|
@ -84,8 +84,8 @@ var wstool = {
|
|||
$('manythreads').disabled = !enabled;
|
||||
$('hello').disabled = !enabled;
|
||||
$('there').disabled = !enabled;
|
||||
$('dump').disabled = !enabled;
|
||||
$('json').disabled = !enabled;
|
||||
$('twain').disabled = !enabled;
|
||||
$('send10k').disabled = !enabled;
|
||||
$('send100k').disabled = !enabled;
|
||||
$('send1000k').disabled = !enabled;
|
||||
|
|
Loading…
Reference in New Issue