summaryrefslogtreecommitdiff
path: root/server/socket.py
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-10-08 18:56:48 +0200
committerAleš Smodiš <aless@guru.si>2015-10-08 18:56:48 +0200
commit76bfb287b51bd97c9ca0bfc4e7760b7ee8e15b47 (patch)
tree1124ec688054e2adb31f8a12c84115ec55381d7a /server/socket.py
parentb6eeda1a66da16f90d02dd5d439d5cc5088c1a88 (diff)
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.
Diffstat (limited to 'server/socket.py')
-rw-r--r--server/socket.py7
1 files changed, 3 insertions, 4 deletions
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()