Sha256: 31e053086389dd044a71ee6b26f998249f22ab1651a4d1c0968157d766cea9f7

Contents?: true

Size: 640 Bytes

Versions: 15

Compression:

Stored size: 640 Bytes

Contents

var url = new URL('/server/connect', window.location.href);
url.protocol = url.protocol.replace('http', 'ws');

console.log("Connecting to server", url);
var server = new WebSocket(url.href);
console.log("Connected to", server);

server.onopen = function(event) {
	chat.onkeypress = function(event) {
		if (event.keyCode == 13) {
			server.send(JSON.stringify({text: chat.value}));
			
			chat.value = "";
		}
	}
};

server.onmessage = function(event) {
	console.log("Got message", event);
	
	var message = JSON.parse(event.data);
	
	var pre = document.createElement('pre');
	pre.innerText = message.text;
	
	response.appendChild(pre);
};

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
async-websocket-0.14.0 examples/utopia/pages/client/client.js
async-websocket-0.13.1 examples/utopia/pages/client/client.js
async-websocket-0.13.0 examples/utopia/pages/client/client.js
async-websocket-0.12.2 examples/utopia/pages/client/client.js
async-websocket-0.12.1 examples/utopia/pages/client/client.js
async-websocket-0.12.0 examples/utopia/pages/client/client.js
async-websocket-0.11.1 examples/utopia/pages/client/client.js
async-websocket-0.11.0 examples/utopia/pages/client/client.js
async-websocket-0.10.0 examples/utopia/pages/client/client.js
async-websocket-0.9.0 examples/utopia/pages/client/client.js
async-websocket-0.8.0 examples/utopia/pages/client/client.js
async-websocket-0.7.0 examples/utopia/pages/client/client.js
async-websocket-0.6.1 examples/utopia/pages/client/client.js
async-websocket-0.6.0 examples/utopia/pages/client/client.js
async-websocket-0.5.0 examples/utopia/pages/client/client.js