From afdb3c0b28715b3d9a0982e4e0504a0cbcf11e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Mon, 14 Sep 2015 14:49:54 +0200 Subject: 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. --- server/user_session.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'server/user_session.py') 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): -- cgit v1.2.1