Compare commits
No commits in common. "4211560f20f424cc328efd069fcb0920a5bfcb74" and "3587d0184ffb0ce59f8ef1bf0efc6869628951a1" have entirely different histories.
4211560f20
...
3587d0184f
|
|
@ -5,7 +5,6 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>InstantChat</title>
|
<title>InstantChat</title>
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="js/jquery-3.3.1.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
// Constants and variables
|
|
||||||
var wsUri = "ws://localhost:8765";
|
|
||||||
|
|
||||||
|
|
||||||
// Initialization
|
|
||||||
function init() {
|
|
||||||
console.log("Init...");
|
|
||||||
openWebSocket();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open WebSocket
|
|
||||||
function openWebSocket() {
|
|
||||||
websocket = new WebSocket(wsUri);
|
|
||||||
websocket.onopen = function(evt) { onOpen(evt) };
|
|
||||||
websocket.onclose = function(evt) { onClose(evt) };
|
|
||||||
websocket.onmessage = function(evt) { onMessage(evt) };
|
|
||||||
websocket.onerror = function(evt) { onError(evt) };
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebSocket event handlers
|
|
||||||
function onOpen(evt) {
|
|
||||||
console.log('Connected to ' + wsUri + '.');
|
|
||||||
|
|
||||||
text = "Meow";
|
|
||||||
console.log('Sending "' + text + '".');
|
|
||||||
websocket.send(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClose(evt) {
|
|
||||||
console.log("Connection closed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMessage(evt) {
|
|
||||||
console.log('Received: "' + evt.data + '".');
|
|
||||||
}
|
|
||||||
|
|
||||||
function onError(evt) {
|
|
||||||
console.error('Error: "' + evt.data + '".');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Run script after page is loaded
|
|
||||||
$(function() {
|
|
||||||
init();
|
|
||||||
});
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue