WebSocket Event Dispatcher #72

Closed
opened 5 months ago by kimimaru · 3 comments
Owner

This feature is intended to provide a means of retrieving data from TRBot in external applications via a WebSocket. How it should work is this:

  • TRBot sets up a WebSocket server.
  • TRBot dispatches specific events with JSON data over the WebSocket. Examples of data include user messages, valid inputs, and input mode votes.
  • External applications can set up WebSocket clients and listen to the server for messages.

This should offload work to external applications that want specific functions but require TRBot's data. This would even allow the host to run the WebSocket on a public server, allowing any client to listen in. This could be useful during a Twitch Plays race, for instance.

Keep the new code in TRBot.Misc. If it starts getting big, consider moving it into a new TRBot.Events project.

This feature is intended to provide a means of retrieving data from TRBot in external applications via a WebSocket. How it should work is this: * TRBot sets up a WebSocket server. * TRBot dispatches specific events with JSON data over the WebSocket. Examples of data include user messages, valid inputs, and input mode votes. * External applications can set up WebSocket clients and listen to the server for messages. This should offload work to external applications that want specific functions but require TRBot's data. This would even allow the host to run the WebSocket on a public server, allowing any client to listen in. This could be useful during a Twitch Plays race, for instance. Keep the new code in `TRBot.Misc`. If it starts getting big, consider moving it into a new `TRBot.Events` project.
kimimaru added the
enhancement
label 5 months ago
kimimaru added this to the TRBot 2.4 project 5 months ago
Poster
Owner

Something to consider: there needs to be a balance to the event dispatcher. If the events are too few and too shallow, they won't be very useful. On the other hand, too many events may heavily complicate the codebase and make changes more difficult down the road.

Something to consider: there needs to be a balance to the event dispatcher. If the events are too few and too shallow, they won't be very useful. On the other hand, too many events may heavily complicate the codebase and make changes more difficult down the road.
Poster
Owner

Ideas for two very powerful events: GetDatabaseValue and SetDatabaseValue.

They might look something like this:

public string GetDatabaseValue(string tableName, string query);
public void SetDatabaseValue(string tableName, string query);

Like the rest of the WebSocket API, the data would be sent and received as JSON. The names of each event are self-explanatory: GetDatabaseValue would retrieve some value from the database, and SetDatabaseValue would set a value in the database.

How powerful these will turn out to be is yet to be determined, but full database access would be ideal.

In this instance, it may be better if the external application simply loads the database and imports the TRBot.Data library to access and manipulate the models through EF Core.

Ideas for two very powerful events: `GetDatabaseValue` and `SetDatabaseValue`. They might look something like this: ```cs public string GetDatabaseValue(string tableName, string query); ``` ```cs public void SetDatabaseValue(string tableName, string query); ``` Like the rest of the WebSocket API, the data would be sent and received as JSON. The names of each event are self-explanatory: `GetDatabaseValue` would retrieve some value from the database, and `SetDatabaseValue` would set a value in the database. How powerful these will turn out to be is yet to be determined, but full database access would be ideal. In this instance, it may be better if the external application simply loads the database and imports the `TRBot.Data` library to access and manipulate the models through EF Core.
Poster
Owner

Completed in 5b37e57ccf. There are currently 7 event types.

Create a separate issue to create a single WebSocket server as there would be two in use if the host set up LiveSplitOne integration.

Completed in https://codeberg.org/kimimaru/TRBot/commit/5b37e57ccfd0b43572656e241dd97b3d0b1098e0. There are currently 7 event types. Create a separate issue to create a single WebSocket server as there would be two in use if the host set up LiveSplitOne integration.
kimimaru closed this issue 3 months ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.