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:
Alex Vargas 2017-03-07 13:11:49 -08:00 committed by Zeger Hendrikse
parent 250cb7c164
commit 62db91ef1f
1 changed files with 5 additions and 2 deletions

View File

@ -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");