diff options
| author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-08-20 18:17:33 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-08-20 18:17:33 -0700 |
| commit | 6f374aac7f4d553c484eecc77c9599be79f2d834 (patch) | |
| tree | 70b1db95de6eab70da2f83f139a80274b01cd1fb /kennel/main.py | |
| parent | b4140460014d1fc134df9127600f6da2346376e3 (diff) | |
| download | kennel.hatecomputers.club-6f374aac7f4d553c484eecc77c9599be79f2d834.tar.gz kennel.hatecomputers.club-6f374aac7f4d553c484eecc77c9599be79f2d834.zip | |
send the initial state to clients
Diffstat (limited to 'kennel/main.py')
| -rw-r--r-- | kennel/main.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/kennel/main.py b/kennel/main.py index 122e40a..17a143b 100644 --- a/kennel/main.py +++ b/kennel/main.py @@ -12,16 +12,16 @@ from fastapi.staticfiles import StaticFiles from kennel.engine.systems.system import SystemType from kennel.engine.systems.network import Event, Publishable, EventType from typing import Annotated, Optional -from .kennel import ( +from kennel.kennel import ( kennel, system_manager, entity_manager, create_session_controllable_entities, ) -from .app import app, templates, logger -from .kennelcats import KennelCatService -from .middleware import logger_middleware -from .config import config +from kennel.app import app, templates, logger +from kennel.kennelcats import KennelCatService +from kennel.middleware import logger_middleware +from kennel.config import config import asyncio import uuid @@ -85,6 +85,16 @@ async def websocket_endpoint( await websocket.accept() logger.info(f"Websocket connection established for session {session}") + await websocket.send_json( + { + "event_type": EventType.INITIAL_STATE, + "data": { + "world": {"width": config.WORLD_WIDTH, "height": config.WORLD_HEIGHT}, + "entities": kennel.entity_manager.to_dict(), + }, + } + ) + session_entities = create_session_controllable_entities(session) try: network_system = system_manager.get_system(SystemType.NETWORK) |
