Skip to content
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

Support for deferred deserializing of incoming gateway messages #2927

Open
Jacherr opened this issue Jul 30, 2024 · 1 comment
Open

Support for deferred deserializing of incoming gateway messages #2927

Jacherr opened this issue Jul 30, 2024 · 1 comment

Comments

@Jacherr
Copy link

Jacherr commented Jul 30, 2024

For larger Discord bots, the ability to proxy the gateway can be very useful for much faster restarts, by only restarting the gateway connection when absolutely necessary.

Several standalone gateway proxies do exist, and as a complete package they can be quite useful. However, there are cases where having a more bespoke solution may be ideal. The ability to receive events in plain text, from a custom process, allows rather more flexibility for things like processing, logging, and in particular choice of channel used to communicate back to the main process. For example, in my case, I take advantage of UNIX named pipes.

Unfortunately, the ability to proxy these events this way through Serenity is greatly inhibited by the lack of a way to get raw string-type events. Sending deserialized objects through any kind of communication channel is essentially impossible, and re-serializing is a large inefficiency.

As a result, it may be useful to have the ability to register a new type of event handler- MessageHandler or similar, which is like RawEventHandler, but does not deserialize the incoming event. Additionally, to accompany this, it may be useful to have a function which does this deserializing into an Event which can be used from the main process, perhaps similar to this.

I don't imagine this will be a ton of work to implement - essentially it's just splitting the steps of RawEventHandler. In any case, if I can be pointed in the right direction of where this should be done I can potentially take a crack at doing it myself, if it is a feature that may be desired.

Thanks!

@cheesycod

This comment was marked as spam.

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

No branches or pull requests

2 participants