Update
This commit is contained in:
parent
408fec350b
commit
b5cee96d7a
8
model.py
8
model.py
@ -22,9 +22,9 @@ class Model:
|
|||||||
|
|
||||||
def assert_model(self):
|
def assert_model(self):
|
||||||
if not "clients" in self.model:
|
if not "clients" in self.model:
|
||||||
self.model["clients"] = []
|
self.model["clients"] = {}
|
||||||
if not "sessions" in self.model:
|
if not "sessions" in self.model:
|
||||||
self.model["sessions"] = []
|
self.model["sessions"] = {}
|
||||||
|
|
||||||
def handle_post(self, data):
|
def handle_post(self, data):
|
||||||
print("I have received P O S T data: " + str(data))
|
print("I have received P O S T data: " + str(data))
|
||||||
@ -50,13 +50,13 @@ class Model:
|
|||||||
def create_client(self) -> str:
|
def create_client(self) -> str:
|
||||||
clientname = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
|
clientname = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
|
||||||
newclient = {"id": clientname}
|
newclient = {"id": clientname}
|
||||||
self.model["clients"].append(newclient)
|
self.model["clients"][clientname] = newclient
|
||||||
return clientname
|
return clientname
|
||||||
|
|
||||||
def create_session(self) -> str:
|
def create_session(self) -> str:
|
||||||
sessionname = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
|
sessionname = base64.b32encode(bytearray(random.randint(0, 0xFF) for _ in range(10)))[:16].decode().lower()
|
||||||
newsession = {"id": sessionname, "clients": []}
|
newsession = {"id": sessionname, "clients": []}
|
||||||
self.model["sessions"].append(newsession)
|
self.model["sessions"][sessionname] = newsession
|
||||||
return sessionname
|
return sessionname
|
||||||
|
|
||||||
def subscribe(self, clientid, socket):
|
def subscribe(self, clientid, socket):
|
||||||
|
Loading…
Reference in New Issue
Block a user