Interface IConnector
The central interface for pub/sub messaging, service calls, and topic management.
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public interface IConnector
Remarks
Obtain an IConnector from FindConnector(Component)
or GetDefaultConnector(). Concrete implementations are discovered
by ConnectorInjector from active BaseConnectionComponent instances in the scene.
Properties
HasConnectionError
Gets a value indicating whether the connector is in an error state.
Declaration
bool HasConnectionError { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
AddNewTopicsListener(Action<ITopicInfo>, bool)
Add a callback to notify on any new topic.
Declaration
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
void Connect()
Disconnect()
Closes the connection to the messaging backend and releases associated resources.
Declaration
void Disconnect()
GetAllTopics()
Return all ITopicInfo ordered by topic name
Declaration
IEnumerable<ITopicInfo> GetAllTopics()
Returns
| Type | Description |
|---|---|
| IEnumerable<ITopicInfo> | The IEnumerable collection of ITopicInfo |
GetTopicInfo(string, MessageDisambiguator)
Gets the ITopicInfo for the specified topic
Declaration
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
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 message 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
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
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
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 client to send requests
Declaration
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
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 Clients may call this frequently, connector is responsible for doing sensible rate limiting
Declaration
void RequestTopicListRefresh()
Subscribe(string, MessageTypeId, Action<IMessage>)
Subscribe a callback for the specified topic
Declaration
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 |
Subscribe<T>(string, Action<T>)
Subscribe a callback for the specified topic
Declaration
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 |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the IMessage handled by the subscriber |