diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-09-15 12:14:30 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-09-15 12:14:30 +0200 |
commit | 9df933ebc3ade50628a26af691693254ed1daa22 (patch) | |
tree | 26fa4689f581eda562fcfd881ea3c9cca7b4ecc5 /server | |
parent | b2b4e40e5333b3182d0a57052640e8a7ecae8619 (diff) | |
parent | cc3a807157d6d2d2c4830afcec90d6614e486b70 (diff) |
Merge branch 'master' of ssh://212.235.189.51:22122/codeq-server
Diffstat (limited to 'server')
-rw-r--r-- | server/__init__.py | 41 | ||||
-rw-r--r-- | server/socket.py | 6 |
2 files changed, 4 insertions, 43 deletions
diff --git a/server/__init__.py b/server/__init__.py index 861a7df..0007e0a 100644 --- a/server/__init__.py +++ b/server/__init__.py @@ -1,6 +1,5 @@ # coding=utf-8 -import multiprocessing.managers from . import user_session from . import prolog_session from . import python_session @@ -8,43 +7,3 @@ from . import socket import server.problems __all__ = ['socket', 'handlers', 'user_session', 'prolog_session', 'python_session', 'problems', 'start'] - - -# TODO: everything below is deprecated, remove it - -class Codeq(object): - _method_to_typeid_ = { - 'get_session_by_id': 'UserSession', - 'get_or_create_session': 'UserSession', - 'authenticate_and_create_session': 'UserSession' - } - - def get_session_by_id(self, sid): - return user_session.get_session_by_id(sid) - - def get_or_create_session(self, uid, username, sid=None): - return user_session.get_or_create_session(uid, username, sid) - - def authenticate_and_create_session(self, username, password): - return user_session.authenticate_and_create_session(username, password) - - def list_problems(self): - return server.problems.list_problems() - -class CodeqManager(multiprocessing.managers.BaseManager): - pass - -class UserSessionProxy(multiprocessing.managers.BaseProxy): - _method_to_typeid_ = {'get_prolog': 'PrologSession', 'get_python': 'PythonSession'} - -CodeqManager.register('PrologSession') -CodeqManager.register('PythonSession') -CodeqManager.register('UserSession', proxytype=UserSessionProxy) -#CodeqManager.register('get_session_by_id', callable=user_session.get_session_by_id, proxytype=UserSessionProxy) -#CodeqManager.register('get_or_create_session', callable=user_session.get_or_create_session, proxytype=UserSessionProxy) -#CodeqManager.register('authenticate_and_create_session', callable=user_session.authenticate_and_create_session, proxytype=UserSessionProxy) -CodeqManager.register('Codeq', callable=Codeq, method_to_typeid=Codeq._method_to_typeid_) - -def start(): - m = CodeqManager(address=('localhost', 16231), authkey=b'c0d3q3y') - m.get_server().serve_forever() diff --git a/server/socket.py b/server/socket.py index c248056..b184d4b 100644 --- a/server/socket.py +++ b/server/socket.py @@ -20,8 +20,10 @@ _transactions_to_socket = {} # keyed by tid, used only when there is no sid ava def processIncomingPacket(receiving_socket, packet): print('Decocoding JSON: {}'.format(packet)) obj = json.loads(packet) - if obj.get('type') == 'connect': + req_type = obj.get('type') # private (meta) requests have the 'type' + if req_type == 'connect': return # TODO: first packet is 'connect', providing the list of connected sessions to the peer + tid = obj.get('tid') # transaction ID if tid is None: raise Exception('Transaction ID is missing from the request') @@ -270,7 +272,7 @@ class Communication(SocketHandler): lock.release() for handler in handlers: handler.destroy() # destroy them all, even the server socket - # this is where everything is destroyed but us, so what follows is self-destruct + # this is where everything has been destroyed but us, so what follows is self-destruct lock.acquire() try: self._destroying = True |