Class DummyConnection
An IConnector implementation for local testing that publishes and subscribes in-memory without a network.
Implements
Inherited Members
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public class DummyConnection : IConnector
Constructors
DummyConnection()
Initializes a new DummyConnection with empty publisher and service collections.
Declaration
public DummyConnection()
Properties
HasConnectionError
Gets a value indicating whether the connector is in an error state.
Declaration
public bool HasConnectionError { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
AddNewTopicsListener(Action<ITopicInfo>, bool)
Add a callback to notify on any new topic.
Declaration
public void AddNewTopicsListener(Action<ITopicInfo> callback, bool notifyAllExistingTopics = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<ITopicInfo> | callback | The callback Action to notify of any new topic |
| bool | notifyAllExistingTopics | Indicates if the callback should be invoked immediately for all existing topics |
Connect()
Opens the connection to the messaging backend.
Declaration
public void Connect()
Disconnect()
Closes the connection to the messaging backend and releases associated resources.
Declaration
public void Disconnect()
GetAllTopics()
Return all ITopicInfo ordered by Topic
Declaration
public IEnumerable<ITopicInfo> GetAllTopics()
Returns
| Type | Description |
|---|---|
| IEnumerable<ITopicInfo> | The IEnumerable collection of ITopicInfo |
GetTopicInfo(string, MessageDisambiguator)
Gets the ITopicInfo for the specified topic
Declaration
public ITopicInfo GetTopicInfo(string topic, MessageDisambiguator disambiguator = MessageDisambiguator.Default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The specified topic |
| MessageDisambiguator | disambiguator | The disambiguator type for the IMessage |
Returns
| Type | Description |
|---|---|
| ITopicInfo | The ITopicInfo for the specified topic |
ImplementService(string, MessageTypeId, MessageTypeId, Func<IMessage, IMessage>)
Create the service listener to handle requests
Declaration
public void ImplementService(string serviceName, MessageTypeId requestTypeId, MessageTypeId responseTypeId, Func<IMessage, IMessage> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceName | The service name |
| MessageTypeId | requestTypeId | The request message type id (name and disambiguator) |
| MessageTypeId | responseTypeId | The response type id (name and disambiguator) |
| Func<IMessage, IMessage> | callback | The callback to handle the request and return the response |
ImplementService<TRequest, TResponse>(string, Func<TRequest, TResponse>)
Create the service listener to handle requests
Declaration
public void ImplementService<TRequest, TResponse>(string serviceName, Func<TRequest, TResponse> callback) where TRequest : IMessage where TResponse : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceName | The service name |
| Func<TRequest, TResponse> | callback | The callback to handle the request and return the response |
Type Parameters
| Name | Description |
|---|---|
| TRequest | The type of the IMessage request |
| TResponse | The type of the IMessage response |
RegisterPublisher(string, MessageTypeId)
Create or get an IPublisher for the specified topic and message type name
Declaration
public IPublisher RegisterPublisher(string topic, MessageTypeId messageTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The specified topic |
| MessageTypeId | messageTypeId | The message type id (name and disambiguator) |
Returns
| Type | Description |
|---|---|
| IPublisher | The IPublisher |
RegisterPublisher<T>(string)
Create or get an IPublisher for the specified topic and message type
Declaration
public IPublisher RegisterPublisher<T>(string topic) where T : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The specified topic |
Returns
| Type | Description |
|---|---|
| IPublisher | The IPublisher |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the IMessage |
RegisterServiceClient(string, MessageTypeId, MessageTypeId)
Create the service listener to handle requests
Declaration
public IServiceClient RegisterServiceClient(string serviceName, MessageTypeId requestTypeId, MessageTypeId responseTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceName | The service name |
| MessageTypeId | requestTypeId | The request message type id (name and disambiguator) |
| MessageTypeId | responseTypeId | The response message type id (name and disambiguator) |
Returns
| Type | Description |
|---|---|
| IServiceClient | The IServiceClient |
RegisterServiceClient<TRequest, TResponse>(string)
Create the service client to send requests
Declaration
public IServiceClient RegisterServiceClient<TRequest, TResponse>(string serviceName) where TRequest : IMessage where TResponse : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceName | The service name |
Returns
| Type | Description |
|---|---|
| IServiceClient | The IServiceClient |
Type Parameters
| Name | Description |
|---|---|
| TRequest | The type of the IMessage request |
| TResponse | The type of the IMessage response |
RequestTopicListRefresh()
Refresh the topic list
Declaration
public void RequestTopicListRefresh()
Subscribe(string, MessageTypeId, Action<IMessage>)
Subscribe a callback for the specified topic
Declaration
public void Subscribe(string topic, MessageTypeId messageTypeId, Action<IMessage> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The specified topic |
| MessageTypeId | messageTypeId | The message type id (name and disambiguator) |
| Action<IMessage> | callback | The subscriber callback Action to handle an IMessage. The callback will be scheduled on the current SynchronizationContext; i.e. the main thread |
Subscribe<T>(string, Action<T>)
Subscribe a callback for the specified topic
Declaration
public void Subscribe<T>(string topic, Action<T> callback) where T : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The specified topic |
| Action<T> | callback | The subscriber callback Action to handle an IMessage. The callback will be scheduled on the current SynchronizationContext; i.e. the main thread |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the IMessage handled by the subscriber |