From 9a4225751a93425f06ad49131da8b9a7a86f2e48 Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Tue, 19 Oct 2021 14:13:08 -0400 Subject: [PATCH 1/3] Made bare bone server that runs. Looking to add proper login and logout functions that users will use to connect and disconnect with the server. --- src/py-cli/make_sockets.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 src/py-cli/make_sockets.py diff --git a/src/py-cli/make_sockets.py b/src/py-cli/make_sockets.py new file mode 100755 index 0000000..85f5eae --- /dev/null +++ b/src/py-cli/make_sockets.py @@ -0,0 +1,37 @@ +""" +A file that makes a bunch of sockets + +@author Lachezar Todorov +""" + +class WebSockestServerExternal(): + + def __init__(self): + self.wsl = [10] + self.count = 0 + + + #start session + def login(self, name): + self.wsl[self.count] = name + self.count += 1 + self.printing() + + #exit session + def logout(self, name): + for name in self.wsl: + if name == name: + index = self.wsl.index(name) + self.wsl[index] = "" + self.printing() + + #print out the list + def printing(self): + for name in self.wsl: + print(name) + +WebSockestServerExternal() + +#alice.login() +#alice.logout() + From 954550408d576c7baa7cbd0b89bcc50167eeec93 Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Tue, 19 Oct 2021 14:14:22 -0400 Subject: [PATCH 2/3] Forgot to add some files that were in the parent directory --- .gitignore | 0 LICENSE | 0 README.md | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 From 83ffa9bd49647190d5194817bf4cbbdebae7aa3f Mon Sep 17 00:00:00 2001 From: hornet Date: Tue, 9 Nov 2021 14:26:54 -0500 Subject: [PATCH 3/3] Added hub code --- src/hub/hub.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/hub/hub.py diff --git a/src/hub/hub.py b/src/hub/hub.py new file mode 100644 index 0000000..8281607 --- /dev/null +++ b/src/hub/hub.py @@ -0,0 +1,22 @@ +""" +Creates hub for distributed IoT + +@author hornetfighter515 +@author Lachezar Todorov +""" + +from websocket_server import WebsocketServer + +def new_client(client, server): + print("Client has joined") + +def message_received(client, server, message): + print(message) + +int_server = WebsocketServer(host='127.0.0.1', port=6872) + + +ext_server = WebsocketServer(host='127.0.0.1', port=6873) +ext_server.set_fn_message_received(message_received) +ext_server.set_fn_new_client(new_client) +ext_server.run_forever()