-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SSE Events to push realtime data from the internal server to the webmap #8
Conversation
A preview of what it looks like when a player is moving around: 2023-10-22.02-52-04.mp4 |
that is actually so cool, really hope this becomes a thing eventually |
I can also only express my utmost interest in this. It looks like an absolute killer feature for this plugin 😎 |
7a6ba37
to
69236bf
Compare
Wohooo more progress 😄 If you need someone to test this out, feel free to get in contact with me. |
I'll most likely release a test build when I think it's ready for testing before I merge it into the main project! I'll make sure to mention you when that happens :) |
69236bf
to
b8801a5
Compare
I'm pretty satisfied with the progress made in this PR. Pending any reported issues regarding code design or bugs resulting from these changes, this PR will be merged sometime next month. During this period, I would like some help from all of you in putting together Apache and NGINX configurations that will allow proper SSE functionality. I have already configured Caddy successfully (example in the PR description), so if anyone has a functioning setup with Apache or Nginx, please share it with me in the Discord server. (SSE prefers batch data transmission, which may hinder real-time updates.) For those interested in conducting tests to ensure consistency, I recommend enabling the debug option in the config file and observing how the logs update between the browser and the server. If properly configured, they should both update simultaneously. Please refer to the video below for a demonstration. If the server logs update instantly while those in the browser do not, it indicates a problem with the reverse proxy configuration. Please report any issues with this PR in the discord server. The auto-updating link to the build with the most recent changes is available at the bottom of the PR description. 2024-03-14.21-17-21.mp4 |
Next month is almost over 😛 I hope to see this merged soon! |
Will be merged into the first build for 1.20.6 :) |
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:
What if I want this but I have the internal server disabled ???
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 set 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:/sse
reverse proxy NGINX example:API Changes
Internally, layers used to update in a per-second basis, which meant everything was configured in seconds. This PR changes that so everything runs in ticks instead. I tried to make sure that all API methods that state "seconds" correctly return or set the update interval as seconds. More specifically, I've overloaded
Layer#setUpdateInterval
andScheduler#addTask(...)
with an extra boolean parameter called ticks that indicates whether to return or accept the interval as ticks.LiveDataHandler.java
A
LiveDataHandler
class has been added to help with pushing data to the SSE endpoints. There is one global SSE handler that sends data to/sse
, and each world has it's own handler that sends data to/sse/<world>
. If you hit/sse/<world>
with an invalid world, you'll receive a JSON error that lists available worlds (worlds that are disabled will not appear). This is not really API, so don't expect it to be stable if it gets changed in the future.Layer.java
The following methods were added to the
Layer
class. Any created layers will by default returnfalse
whenisLiveUpdate()
is called, which will stop the layer from being pushed through SSE. If you believe that your custom layers should be able to update through SSE, then callsetLiveUpdate(true)
when creating your layer.Download the pl3xmap jar for this pull request: pl3xmap-8.zip