Skip to content

Commit 96dfb61

Browse files
Create messenger.md
1 parent 54e4a61 commit 96dfb61

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Docs/messenger.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# MSU Messenger
2+
3+
Using gPRC, the MSU Randomizer can send details to other applications when a MSU has been generated or when the MSU Randomizer has detected a new track.
4+
5+
When a client application uses the [IMsuMessageReceiver](https://github.com/MattEqualsCoder/MSURandomizer/blob/main/MSURandomizerLibrary/Messenger/IMsuMessageSender.cs), the service will pick a random port and spin up a gPRC server. It will write the address to a file in the MSU Randomizer folder, which the MSU Randomizer application will use to send messages to.
6+
7+
You can find the gRPC proto file [here](https://github.com/MattEqualsCoder/MSURandomizer/blob/main/MSURandomizerLibrary/Messenger/MsuRandomizer.proto), or you can utilize it in any .net application that uses the [MSURandomizer Library nuget package](https://www.nuget.org/packages/MattEqualsCoder.MSURandomizer.Library/).
8+
9+
## Diagram
10+
11+
![MSUMessenger drawio(1)](https://github.com/user-attachments/assets/44af65c5-6e46-498f-b7a1-80e1df7e55ce)
12+
13+
## Basic Example
14+
15+
```CSharp
16+
messageReceiver.Initialize();
17+
18+
messageReceiver.MsuGenerated += (sender, args) =>
19+
{
20+
logger.LogInformation("MSU {Name} generated", args.Msu.Name);
21+
};
22+
23+
messageReceiver.TrackChanged += (sender, args) =>
24+
{
25+
logger.LogInformation("Msu track changed to: {SongName}", args.Track.GetDisplayText(TrackDisplayFormat.Horizontal));
26+
};
27+
```

0 commit comments

Comments
 (0)