add authenticate on socket connect

This commit is contained in:
Enrique Hernandez 2021-02-09 17:07:45 -06:00
commit e0da50eb27
7 changed files with 112 additions and 70 deletions

17
src/modules/socket.ts Normal file
View file

@ -0,0 +1,17 @@
interface SocketState {
connection: WebSocket | null;
auth: boolean;
}
// Create WebSocket connection.
const socket = new WebSocket('ws://localhost:8080');
// Connection opened
socket.onopen = function (event) {
socket.send('Hello Server!');
}
socket.onmessage = function(event) {
console.debug("WebSocket message received:", event);
}