summaryrefslogtreecommitdiff
path: root/server/user_session.py
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-09-14 14:49:54 +0200
committerAleš Smodiš <aless@guru.si>2015-09-14 14:49:54 +0200
commitafdb3c0b28715b3d9a0982e4e0504a0cbcf11e70 (patch)
treed052125c6fc4fb4803b10dd20d3c24fc3a2711f9 /server/user_session.py
parentd82013c214021d6e5480d18105760fa70cfc708b (diff)
Reimplemented communication with the client side.
* Implemented a node web server supporting asynchronous websocket and long-polling communication with clients. * Implemented TCP communication between python middleware and node web server.
Diffstat (limited to 'server/user_session.py')
-rw-r--r--server/user_session.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/server/user_session.py b/server/user_session.py
index f21102c..5eec743 100644
--- a/server/user_session.py
+++ b/server/user_session.py
@@ -8,6 +8,7 @@ import random
from . import prolog_session
from . import python_session
from . import problems
+from . import handlers
import db
from errors.session import NoSuchSession, AuthenticationFailed
import psycopg2.extras
@@ -128,6 +129,16 @@ class UserSession(object):
finally:
db.return_connection(conn)
+ def send(self, json_obj):
+ """Sends a message to the user.
+
+ This method may be used only for messages that are not replies to requests.
+ For replies use the reply() method on the Request object.
+ :param json_obj: a dict representing the json message
+ :return: None
+ """
+ handlers.send(None, self.sid, json_obj)
+
def __del__(self):
# no locking needed if GC is removing us, as there cannot be any concurrent access by definition
if hasattr(self, 'prolog_session') and (self.prolog_session is not None):