-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add Server-Sent Events #16
base: master
Are you sure you want to change the base?
Conversation
CompletableFuture.allOf( | ||
clients.stream() | ||
.map(client -> CompletableFuture.runAsync(() -> client.sendEvent(event, message))) | ||
.toArray(CompletableFuture[]::new) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified, the result of the futures is ignored so combining them into one is redundant.
(requires adding a plugin field obviously)
CompletableFuture.allOf( | |
clients.stream() | |
.map(client -> CompletableFuture.runAsync(() -> client.sendEvent(event, message))) | |
.toArray(CompletableFuture[]::new) | |
); | |
for (final SseClient client : clients) { | |
plugin.getServer().getAsyncScheduler().runNow(plugin, task -> client.sendEvent(event, message)); | |
} |
import net.earthmc.emcapi.manager.SSEManager; | ||
|
||
|
||
public class PlayerConnectionListener implements Listener { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that player join/quit events are too intrusive, this class should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shadow Warriorrrr's opinion, those events are intrusive though, it can prove helpful to have it...
Imo, the event names could cause some confusion, for example "DeleteNation" sounds like the event deletes the nation.
|
This PR adds a
/events
endpoint to the API that users can use as an EventSource. This endpoint relays and broadcasts multiple Towny events in real time, using server-sent events (SSE) through Javalin. The complete list and data structure can be found in the docs.