-
Notifications
You must be signed in to change notification settings - Fork 33
Rework events #262
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
Rework events #262
Conversation
Events was implemented this way since the initial release of replicon (it was more then a year ago, time flies quickly!), but it have some flaws: - Public API for custom ser/de require user to define the whole sending and receiving functions which is not ergonomic. It's especially bad for server events where user need to use a few public helpers that we provided to reduce the boilerplate. - It creates a new set of systems for each replicon event. It's not very efficient and Bevy recently did [a nice optimization](bevyengine/bevy#12936) which we also can do. It won't be that noticeable since user register much less amount of replicon events, but nice to have. I think it's time to revisit the implementation and fix the mentioned flaws.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #262 +/- ##
==========================================
+ Coverage 90.79% 90.86% +0.06%
==========================================
Files 37 36 -1
Lines 2076 2310 +234
==========================================
+ Hits 1885 2099 +214
- Misses 191 211 +20 ☔ View full report in Codecov by Sentry. |
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.
look good.
src/client_event.rs
Outdated
/// Type-erased functions and metadata for a registered client event. | ||
/// | ||
/// Needed to process all events in a single system and call its functions without knowing the type. | ||
struct ClientEventData { |
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 it worth to move this and server structs into their own modules.
I will do it after the review in this PR since I marked it as ready for review and don't want to disrupt the process.
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 implementation breaks my use-case, which injects custom send/receive systems. I don't think there is a way to continue supporting my use-case (which is focused on exposing a single synchronized event stream), so I will just reimplement the missing pieces in my project.
src/client_event.rs
Outdated
/// # Safety | ||
/// | ||
/// The caller must ensure that `events` is [`Events<E>`] and `server_events` is [`Events<ToClients<E>>`]. | ||
unsafe fn resend_locally<E: Event>(events: PtrMut, client_events: PtrMut) { |
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.
unsafe fn resend_locally<E: Event>(events: PtrMut, client_events: PtrMut) { | |
unsafe fn resend_locally<E: Event>(client_events: PtrMut, events: PtrMut) { |
Match the order of use.
Thanks! |
No logical changes, just a move.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #262 +/- ##
==========================================
+ Coverage 90.83% 90.86% +0.03%
==========================================
Files 37 36 -1
Lines 2084 2310 +226
==========================================
+ Hits 1893 2099 +206
- Misses 191 211 +20 ☔ View full report in Codecov by Sentry. |
Superseded #259.
Events was implemented this way since the initial release of replicon (it was more then a year ago, time flies quickly!), but it have some flaws:
I think it's time to revisit the implementation and fix the mentioned flaws.