From 88d204c75200d3185dd70cc583e69f57f3550b09 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 6 Jul 2014 16:23:47 +0200 Subject: Add authentication events --- views/client.html | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'views') diff --git a/views/client.html b/views/client.html index c322042..ebb3810 100644 --- a/views/client.html +++ b/views/client.html @@ -5,6 +5,8 @@ + +
@@ -43,9 +45,9 @@ var socket; var socketConnected = false; - function connectSocket(channel, password) { + function connectSocket(channel, password, authenticate) { socket = io.connect("/", { - "query" : "channel=" + channel + "&password=" + password, + "query" : "channel=" + channel + ( authenticate ? "&password=" + password : ""), "force new connection" : true }); @@ -59,6 +61,20 @@ println("disconnected"); }); + socket.on("unknown_channel", function() { + changeControlState(false); + println("unknown_channel"); + }); + + socket.on("authentication_error", function() { + changeControlState(false); + println("authentication_error"); + }); + + socket.on("authenticated", function() { + println("authenticated"); + }); + socket.on("message", function(message) { println(message); }); @@ -70,7 +86,7 @@ if (socketConnected) { socket.disconnect(); } else { - connectSocket(channelField.value, passwordField.value); + connectSocket(channelField.value, passwordField.value, usePassword.checked); } }); -- cgit v1.2.3