Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Use SSE Events to push realtime data from the internal server to the webmap #201

Draft
wants to merge 8 commits into
base: v3
Choose a base branch
from

Conversation

granny
Copy link
Collaborator

@granny granny commented Oct 22, 2023

Overview

This pull request introduces the integration of Server-Sent Events (SSE) into our internal webserver, enabling real-time data updates for our webmap. Using SSE we can achieve seamless real-time updates, significantly enhancing the user experience.

Details

Here are the key features and functionalities that this pull request will bring:

  1. SSE provides real-time player position updates, allowing the webmap to track and display accurate player positions as they rotate and run around.
  2. SSE facilitates immediate marker updates, making sure that any adjustments or additions to markers are instantly reflected on the webmap.
  3. In cases where SSE connections are closed or nonexistent, the system gracefully falls back to updating through the old system, which is done through files.
  4. When an SSE connection is established, the frontend bypasses file-based checks entirely.

What if I want this but I have the internal server off???

You can still get the advantages of this change if you use an external server. Just re-enable the internal web server under a different port and setting up a reverse proxy that points only to the /sse endpoint. This means you can gain the functionality of real-time data updates while the server is running, while also keeping the map available to view, even if the minecraft server is offline.

/sse reverse proxy Caddy example:
map.example.com {
    root * /var/www/map.example.com/
    file_server

    handle_path /sse* {
        rewrite * /sse{uri}
        reverse_proxy localhost:1234
    }

    @gz {
        path *.gz
    }

    handle @gz {
        header Content-Encoding gzip
    }
}

TODO:

  • adjust how often the SSE task should run (currently every tick, maybe increase?)
  • better SSE disconnection handling
  • better SSE handling in webmap
  • fallback to old system if data from SSE takes longer than a second?
  • clean up implementation
  • remove SSE_EVENTS option
  • anything else i think of

@granny
Copy link
Collaborator Author

granny commented Oct 22, 2023

A preview of what it looks like when a player is moving around:

2023-10-22.02-52-04.mp4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant