more packets for changing actions, prose, etc
This commit is contained in:
@@ -13,8 +13,14 @@ async def check(websocket):
|
|||||||
if packet["type"] == "user_joined":
|
if packet["type"] == "user_joined":
|
||||||
IDs[websocket] = packet["name"]
|
IDs[websocket] = packet["name"]
|
||||||
websockets.broadcast(connected, json.dumps({"type": "server_message", "message": IDs[websocket] + " joined"}))
|
websockets.broadcast(connected, json.dumps({"type": "server_message", "message": IDs[websocket] + " joined"}))
|
||||||
|
websockets.broadcast(connected, json.dumps({"type": "view", "loc": "blueland"}))
|
||||||
|
websockets.broadcast(connected, json.dumps({"type": "portrait", "npc": "pink"}))
|
||||||
|
websockets.broadcast(connected, json.dumps({"type": "prose", "clear_box": "true", "message": "You are in Chatland. "}))
|
||||||
|
websockets.broadcast(connected, json.dumps({"type": "action", "clear_box": "true", "actions": ["\"Where am I?\"","Talk to Godot Head","Catch New Pet","Leave"]}))
|
||||||
elif packet["type"] == "shout" or packet['type'] == "server_message":
|
elif packet["type"] == "shout" or packet['type'] == "server_message":
|
||||||
websockets.broadcast(connected, json.dumps({"type": "shout", "name": IDs[websocket], "message": packet["message"]}))
|
websockets.broadcast(connected, json.dumps({"type": "shout", "name": IDs[websocket], "message": packet["message"]}))
|
||||||
|
websockets.broadcast(connected, json.dumps({"type": "view", "loc": "yellowland"}))
|
||||||
|
websockets.broadcast(connected, json.dumps({"type": "portrait", "npc": "blue"}))
|
||||||
|
|
||||||
|
|
||||||
async def handler(websocket):
|
async def handler(websocket):
|
||||||
@@ -29,11 +35,9 @@ async def handler(websocket):
|
|||||||
if websocket in connected:
|
if websocket in connected:
|
||||||
connected.remove(websocket)
|
connected.remove(websocket)
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
async with websockets.serve(handler, "", 8080):
|
async with websockets.serve(handler, "", 8080):
|
||||||
await asyncio.Future() # run forever
|
await asyncio.Future() # run forever
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|||||||
Reference in New Issue
Block a user