diff options
author | Teddy <[email protected]> | 2013-08-22 20:25:12 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-22 20:25:12 +0800 |
commit | 8d47f6890d31d1eac483249de99c846f59366c60 (patch) | |
tree | d9b82b1169f585165a353e5f59478a4c65f9dd63 | |
parent | 8ce3ddb36770bf508cccd85e2129e7ab4f428c01 (diff) |
...
-rw-r--r-- | server/piztor_server.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/server/piztor_server.py b/server/piztor_server.py index 3809f22..4845748 100644 --- a/server/piztor_server.py +++ b/server/piztor_server.py @@ -26,7 +26,7 @@ class DataManager(object): pass class UserManager(DataManager): - def handle(self, opt_type, data): + def authentication_handle(self, opt_type, data): print "Parsing User Data" pos = -1 for i in xrange(0, len(data)): @@ -45,7 +45,7 @@ class UserManager(DataManager): class MesgManager(DataManager): - def handle(self, opt_type, data): + def mesg_sending_handle(self, opt_type, data): print "Parsing Mesg Data" try: if len(data) < 8: @@ -58,7 +58,7 @@ class MesgManager(DataManager): raise ReqInvalidError() class LocationManager(DataManager): - def handle(self, opt_type, data): + def location_update_handle(self, opt_type, data): print "Parsing Loc Data" try: if len(data) < 8: @@ -73,9 +73,13 @@ class LocationManager(DataManager): class PiztorServer(): - mgr_map = [ UserManager(), - MesgManager(), - LocationManager() ] + user_mgr = UserManager() + mesg_mgr = MesgManager() + location_mgr = LocationManager() + + mgr_map = [ user_mgr.authentication_handle, + mesg_mgr.mesg_sending_handle, + location_mgr.location_update_handle ] class GenericHandler(SocketServer.StreamRequestHandler): @@ -101,8 +105,7 @@ class PiztorServer(): if len(data) < 1: raise ReqInvalidError() opt_id = struct.unpack("!B", data[0])[0] - reply = PiztorServer.mgr_map[opt_id].handle( - opt_id, data[1:]) + reply = PiztorServer.mgr_map[opt_id](opt_id, data[1:]) sock.sendall(reply) sock.close() |