Skip to content

Commit

Permalink
Sockets Added
Browse files Browse the repository at this point in the history
  • Loading branch information
devram2000 committed May 5, 2023
1 parent 6ada5da commit 0f8f975
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 4 deletions.
2 changes: 1 addition & 1 deletion norms/ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ def main() -> None:
print("\n")


main()
# main()
2 changes: 1 addition & 1 deletion norms/ball_blackboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,4 @@ def main() -> None:
print("\n")


main()
# main()
2 changes: 1 addition & 1 deletion norms/deliver_medicine.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,4 @@ def main() -> None:
print("\n")


main()
# main()
2 changes: 1 addition & 1 deletion norms/deliver_medicine_with_deontic.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,4 @@ def main() -> None:
print("\n")


main()
# main()
4 changes: 4 additions & 0 deletions norms/deliver_medicine_with_reorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
blackboard.canEnterElevator = False
blackboard.isElevatorOn7th = False
blackboard.canLeaveElevator = False
# print(blackboard)
# exit()



def description() -> str:
"""
Expand Down
12 changes: 12 additions & 0 deletions norms/norms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
print("")
print("Cabinet is locked.")
print("Would you like to change the priorities of actions?")
print("")
print("A - Try Unlocking Cabinet again")
print("B – Wait 10 seconds")
print("C – Call supervisor for remote unlock")
print("")
print("Which action should I take first? (type A, B, or C) _")
print("Which action should I take second? (type A, B, or C) _")
print("")
print("")
28 changes: 28 additions & 0 deletions norms/wsocket.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket Test</title>
</head>

<body>
<script>
// Create WebSocket connection.
const socket = new WebSocket("ws://localhost:8765");

// Connection opened
socket.addEventListener("open", (event) => {
socket.send("Hello Server!");
});

// Listen for messages
socket.addEventListener("message", (event) => {
console.log("Message from server:", event.data);
});
</script>
</body>

</html>
15 changes: 15 additions & 0 deletions norms/wsocket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python

import asyncio
from websockets.server import serve

async def echo(websocket):
async for message in websocket:
print("Message from client:", message)
await websocket.send("Hello client")

async def main():
async with serve(echo, "localhost", 8765):
await asyncio.Future() # run forever

asyncio.run(main())

0 comments on commit 0f8f975

Please sign in to comment.