From 76bfb287b51bd97c9ca0bfc4e7760b7ee8e15b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Thu, 8 Oct 2015 18:56:48 +0200 Subject: Reworked session handling. * All requests have a session ID, except for the initial create_session system messages. * User session can be in an authenticated or anonymous state. * In anonymous state it is not possible to perform user actions. * Logout has been implemented. * Sessions timeout and are cleared after a period of inactivity (1 hour). * Bugfixed the lang setting handling. * Renamed get_problem -> get_current_solution, return only the user's current solution, not the whole problem data. --- server/socket.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'server/socket.py') diff --git a/server/socket.py b/server/socket.py index ae2068f..561ab29 100644 --- a/server/socket.py +++ b/server/socket.py @@ -206,13 +206,12 @@ class JsonClientSocket(SocketHandler): # TODO: unregister from any internal mechanisms def send(self, json_obj): - js = json.dumps(json_obj) - m = str(len(js)) + u':' + js - bytes = m.encode('utf-8') + b = json.dumps(json_obj).encode('utf-8') + b = bytes(str(len(b)), 'utf-8') + b':' + b lock = self._write_lock lock.acquire() try: - self.socket.sendall(bytes) + self.socket.sendall(b) finally: lock.release() -- cgit v1.2.1