diff --git a/Lab_3/Twidder/server.py b/Lab_3/Twidder/server.py index d8b132cbeecff3417d820e9a1b25d4e9a0ba1be1..e85ba16005b693611dace5af2a98006a4b60807c 100644 --- a/Lab_3/Twidder/server.py +++ b/Lab_3/Twidder/server.py @@ -85,19 +85,36 @@ def echo(socket): return # sign out if I am logged in somewhere else + + print("Before loop") + print("/n") print(session) + print("/n") + for token in list(session.keys()): - if session[token][0] == myEmail and token != myToken: - if session[token][1] != "": - session[token][1].send(json.dumps({"action" : "signOut"})) - session[token][1].close() + if session[token][0] == myEmail and token != myToken and session[token][1] != "": + print("Inside first if") + #if session[token][1] != "": + print("Inside second if") + session[token][1].send(json.dumps({"action" : "signOut"})) + print(token[1]) + session[token][1].close() print("You got kicked out") session.pop(token) + + print("After loop") + print("/n") print(session) + print("/n") # Put socket in global dict so server knows my connection is open session[myToken] = (myEmail, socket) + + print("After insertion into dict") + print("/n") print(session) + print("/n") + socket.send(json.dumps({"action" : "signIn"})) @@ -123,7 +140,7 @@ def sign_in(): return jsonify({}), 404 #"No user found by your email" if password != rows[1]: - return jsonify({}), 401 #"Incorrect password") + return jsonify({}), 401 #"Incorrect password") x # Generate a random token token = str(uuid.uuid4()) diff --git a/Lab_3/Twidder/static/client.js b/Lab_3/Twidder/static/client.js index a4995c8c8e36ea8091923a9d74a35ceb0cb90c13..95fc651fc1894aa66dc4c94f5a2e395920672fc0 100644 --- a/Lab_3/Twidder/static/client.js +++ b/Lab_3/Twidder/static/client.js @@ -17,7 +17,6 @@ function connectWithSocket() { displayView(); setUserDetails("home"); - // Establish web socket socket = new WebSocket('ws://' + document.domain + ':5000/myServer/api'); @@ -37,7 +36,7 @@ function connectWithSocket() { case "signOut": // If old socket open, close it. - socket.close(); + //socket.close(); console.log(response); // Reset token in the localStorage