Bael 389 - Building URL dynamically between host and pathname (#1323)
* Project for " A Guide to the Java API for WebSocket" article * Setting dependencies correctly * Formatting adjustments * Removing tomcat7 maven plugin * Applying formatt - No spaces * BAEL-389 - Building URL dynamically between host and pathname
This commit is contained in:
parent
250cb7c164
commit
62db91ef1f
|
@ -2,8 +2,11 @@ var ws;
|
|||
|
||||
function connect() {
|
||||
var username = document.getElementById("username").value;
|
||||
ws = new WebSocket("ws://" + document.location.host + "/java-websocket/chat/" + username);
|
||||
|
||||
|
||||
var host = document.location.host;
|
||||
var pathname = document.location.pathname;
|
||||
|
||||
ws = new WebSocket("ws://" +host + pathname + "chat/" + username);
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
var log = document.getElementById("log");
|
||||
|
|
Loading…
Reference in New Issue