diff --git a/Server/Server.py b/Server/Server.py index e1e43d9..be6b41c 100644 --- a/Server/Server.py +++ b/Server/Server.py @@ -4,44 +4,44 @@ import DataTypes from .AsyncServer import Server class vHandler(Server.Handler): - def setup(self): - Logging.info("Handler for '%s' initalised." % self.info[0]) - self.authed = False - self.users = self.kwargs.pop("users") + def setup(self): + Logging.info("Handler for '%s' initalised." % self.info[0]) + self.authed = False + self.users = self.kwargs.pop("users") - def handle(self, data, type): - if not self.authed: - if type == DataTypes.json: - self.auth(data) + def handle(self, data, type): + if not self.authed: + if type == DataTypes.json: + self.auth(data) - def finish(self): - Logging.info("%s disconnected." % self.info[0]) + def finish(self): + Logging.info("%s disconnected." % self.info[0]) - def auth(self, collection): - if "auth" in collection: - if "user" and "pw" in collection["auth"]: - temp_user = User(collection["auth"]["user"], collection["auth"]["pw"]) - if temp_user in self.users: - self.sock.send({"auth" : "success"}) - self.authed = True - return - self.sock.close() + def auth(self, collection): + if "auth" in collection: + if "user" and "pw" in collection["auth"]: + temp_user = User(collection["auth"]["user"], collection["auth"]["pw"]) + if temp_user in self.users: + self.sock.send({"auth" : "success"}) + self.authed = True + return + self.sock.close() class User: - def __init__(self, username, password): - self.username = username - self.password = password + def __init__(self, username, password): + self.username = username + self.password = password - def __eq__(self, other): - if self.username == other.username and self.password == other.password: - return True - return False + def __eq__(self, other): + if self.username == other.username and self.password == other.password: + return True + return False - def __repr__(self): - return self.username + def __repr__(self): + return self.username server = Server("127.0.0.1", 1337, vHandler, {"users" : [User("test", "123")]}) \ No newline at end of file