Show / Hide Table of Contents

Class Messenger

Represents helper methods allow to communicate with remove cluster members through network.

Inheritance
object
Messenger
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Net.Cluster.Messaging
Assembly: DotNext.Net.Cluster.dll
Syntax
public static class Messenger

Methods

| Edit this page View Source

ReadAsTextAsync(IMessage, CancellationToken)

Converts message content into string.

Declaration
public static Task<string> ReadAsTextAsync(this IMessage message, CancellationToken token = default)
Parameters
Type Name Description
IMessage message

The message to read.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
Task<string>

The content of the message.

| Edit this page View Source

SendBroadcastSignalAsync(IMessageBus, IMessage, bool)

Send broadcast one-way message to all members in the cluster except local member.

Declaration
public static Task SendBroadcastSignalAsync(this IMessageBus cluster, IMessage message, bool requiresConfirmation = true)
Parameters
Type Name Description
IMessageBus cluster

The cluster of nodes.

IMessage message

The message to be sent.

bool requiresConfirmation

true to wait for confirmation of delivery from receiver; otherwise, false.

Returns
Type Description
Task

The task representing asynchronous execution of broadcasting.

| Edit this page View Source

SendJsonMessageAsync<TRequest, TResponse>(ISubscriber, MessageReader<TResponse>, string, TRequest, CancellationToken)

Sends synchronous message with JSON payload.

Declaration
public static Task<TResponse> SendJsonMessageAsync<TRequest, TResponse>(this ISubscriber messenger, MessageReader<TResponse> responseReader, string messageName, TRequest request, CancellationToken token) where TRequest : IJsonSerializable<TRequest>
Parameters
Type Name Description
ISubscriber messenger

The receiver of the message.

MessageReader<TResponse> responseReader

The response reader.

string messageName

The name of the message.

TRequest request

JSON-serializable request.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
Task<TResponse>

The deserialized response.

Type Parameters
Name Description
TRequest

The type of outbound message.

TResponse

The type of inbound message.

| Edit this page View Source

SendJsonSignalAsync<TSignal>(ISubscriber, string, TSignal, bool, CancellationToken)

Sends one-way message with JSON payload.

Declaration
public static Task SendJsonSignalAsync<TSignal>(this ISubscriber messenger, string messageName, TSignal signal, bool requiresConfirmation = true, CancellationToken token = default) where TSignal : IJsonSerializable<TSignal>
Parameters
Type Name Description
ISubscriber messenger

The receiver of the message.

string messageName

The name of the message.

TSignal signal

JSON-serializable signal.

bool requiresConfirmation

true to wait for confirmation of delivery from receiver; otherwise, false.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
Task

The task representing asynchronous execution of the method.

Type Parameters
Name Description
TSignal

JSON-serializable type of signal payload.

| Edit this page View Source

SendTextMessageAsync<TResponse>(ISubscriber, MessageReader<TResponse>, string, string, string?, CancellationToken)

Send synchronous text message.

Declaration
public static Task<TResponse> SendTextMessageAsync<TResponse>(this ISubscriber messenger, MessageReader<TResponse> responseReader, string messageName, string text, string? mediaType = null, CancellationToken token = default)
Parameters
Type Name Description
ISubscriber messenger

The receiver of the message.

MessageReader<TResponse> responseReader

The response reader.

string messageName

The name of the message.

string text

The content of the message.

string mediaType

The media type of the message content.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
Task<TResponse>

The reply message.

Type Parameters
Name Description
TResponse

The type of the parsed response message.

| Edit this page View Source

SendTextSignalAsync(ISubscriber, string, string, bool, string?, CancellationToken)

Send one-way text message.

Declaration
public static Task SendTextSignalAsync(this ISubscriber messenger, string messageName, string text, bool requiresConfirmation = true, string? mediaType = null, CancellationToken token = default)
Parameters
Type Name Description
ISubscriber messenger

The receiver of the message.

string messageName

The name of the message.

string text

The content of the message.

bool requiresConfirmation

true to wait for confirmation of delivery from receiver; otherwise, false.

string mediaType

The media type of the message content.

CancellationToken token

The token that can be used to cancel asynchronous operation.

Returns
Type Description
Task

The task representing asynchronous execution of the method.

  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾