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

Fixing gatsby highlights #639

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions site/content/documentation/v0.1.0-alpha.4/message-router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Message Router is an ASP.NET Core-based backend service that exposes one or
Message Router Server can be setup in .NET by adding to the `ServiceCollection` and its configuration like `MessageRouterWebSocketServerOptions` after you have added the nuget package: `MorganStanley.ComposeUI.Messaging.Server`.

Example:
```C#
```csharp
IHostBuilder builder = new HostBuilder();

builder.ConfigureServices(
Expand Down Expand Up @@ -46,7 +46,7 @@ where with the `ConfigureServer` method the `MessageRouterWebSocketServerOptions
The server implementation is only available on the .NET side.

Also the Message Router Client can be set up in .NET easily with dependecy injection. You are able to call the `AddMessageRouter()` extension method on a `IServiceCollection` where you can configure `MessageRouterWebSocketOptions` - [reference](https://github.com/morganstanley/ComposeUI/blob/main/src/messaging/dotnet/src/Client/Client/WebSocket/MessageRouterWebSocketOptions.cs), within the `.UseWebSocket()` builder method and the AccessToken with the `UseAccessToken` after you have added the nuget package: `MorganStanley.ComposeUI.Messaging.Client`.
```C#
```csharp
var services = new ServiceCollection()
.AddMessageRouter(
mr => mr
Expand Down Expand Up @@ -90,7 +90,7 @@ await client.connect();
Use the subscribe method of the client to set a handler on a topic. The message parameter of the handler method contains the payload as a string. The following example parses a JSON payload from the "exampleTopic" topic and logs it to console.

- .NET
```C#
```csharp
ValuTask HandleTopicMessage(MessageBuffer? payload)
{
Console.WriteLine(payload.GetString());
Expand All @@ -115,7 +115,7 @@ Use the subscribe method of the client to set a handler on a topic. The message
#### Publish a message
Use the publish method of the client to publish a message to a topic. The payload of the message must be a string. The following example creates a JSON string out of an object, and publishes it to the "exampleTopic" topic.
- .NET
```C#
```csharp
await _messageRouter.PublishAsync(
'exampleTopic',
MessageBuffer.Factory.CreateJson(payloadObject, _jsonSerializerOptions));
Expand All @@ -130,7 +130,7 @@ Use the publish method of the client to publish a message to a topic. The payloa
#### Invoking a service
Use the invoke method of the client to invoke a registered service's handler and get the response from it. The payload must be a string.
- .NET
```C#
```csharp
var resultBuffer = await _messageRouter.InvokeAsync(
"exampleTopic",
MessageBuffer.Factory.CreateJson(payloadObject, _jsonSerializerOptions));
Expand All @@ -146,7 +146,7 @@ Use the invoke method of the client to invoke a registered service's handler and
#### Registering a service
Use the register service method to register a service by providing its name and its handler. The handler should return the type of `MessageBuffer?` so when a client calls the service they will receive the response from the registered handler function.
- .NET
```C#
```csharp
await _messageRouter.RegisterServiceAsync(
"exampleTopic",
(endpoint, payload, context) =>
Expand All @@ -167,7 +167,7 @@ Use the register service method to register a service by providing its name and
#### Unregistering a service
Use the unregister service method if you want to remove the service registration.
- .NET
```C#
```csharp
await _messageRouter.UnregisterServiceAsync("exampleTopic", cancellationToken);
```

Expand All @@ -181,7 +181,7 @@ Use register an endpoint method if you want to register an endpoint by providing
The invoke request in this case would be solved "locally".

- .NET
```C#
```csharp
await _messageRouter.RegisterEndpointAsync(
"exampleTopic",
(endpoint, payload, context) =>
Expand All @@ -203,7 +203,7 @@ The invoke request in this case would be solved "locally".
Use the unregister endpoint method if you want to remove an endpoint.

- NET
```C#
```csharp
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(2));
await _messageRouter.UnregisterEndpointAsync("exampleTopic", cancellationTokenSource.Token);
```
Expand Down
Loading