Class Communicator
- Namespace
- Ice
- Assembly
- Ice.dll
Communicator is the central object in Ice. Its responsibilities include:
- creating and managing outgoing connections
- executing callbacks in its client thread pool
- creating and destroying object adapters
- loading plug-ins
- managing properties (configuration), retries, logging, instrumentation, and more.
A Communicator is usually the first object you create when programming with Ice. You can create multiple communicators in a single program, but this is not common.
public sealed class Communicator : IDisposable, IAsyncDisposable
- Inheritance
-
Communicator
- Implements
- Inherited Members
Constructors
Communicator(InitializationData?)
Initializes a new instance of the Communicator class.
public Communicator(InitializationData? initData = null)
Parameters
initDataInitializationDataOptions for the new communicator.
Communicator(ref string[])
Initializes a new instance of the Communicator class, using Ice properties parsed from
command-line arguments. This constructor uses args to create the Properties
of the new communicator.
public Communicator(ref string[] args)
Parameters
argsstring[]The command-line arguments.
Properties
shutdownCompleted
Gets a task that completes when the communicator's shutdown completes. This task always completes successfully.
public Task shutdownCompleted { get; }
Property Value
Remarks
The shutdown of a communicator completes when all its incoming connections are closed. Awaiting this task is equivalent to calling waitForShutdown().
- See Also
Methods
Dispose()
Disposes this communicator. This method calls shutdown() implicitly. Calling dispose destroys all object adapters, and closes all outgoing connections. This method waits for all outstanding dispatches to complete before returning. This includes "bidirectional dispatches" that execute on outgoing connections.
public void Dispose()
DisposeAsync()
Disposes this communicator asynchronously. Like shutdownCompleted, this method waits for all outstanding dispatches to complete.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that completes when the communicator is disposed.
addAdminFacet(Object, string)
Adds a new facet to the Admin object. Adding a servant with a facet that is already registered throws AlreadyRegisteredException.
public void addAdminFacet(Object servant, string facet)
Parameters
servantObjectThe servant that implements the new Admin facet.
facetstringThe name of the new Admin facet.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
addSliceLoader(SliceLoader)
Adds a Slice loader to this communicator, after the Slice loader set in InitializationData(if any) and after other Slice loaders added by this method.
public void addSliceLoader(SliceLoader loader)
Parameters
loaderSliceLoaderThe Slice loader to add.
Remarks
This method is not thread-safe and should only be called right after the communicator is created. It's provided for applications that cannot set the Slice loader in the InitializationData of the communicator, such as IceBox services.
createAdmin(ObjectAdapter, Identity)
Adds the Admin object with all its facets to the provided object adapter. If Ice.Admin.ServerId is set and the provided object adapter has a Locator, createAdmin registers the Admin's Process facet with the Locator's LocatorRegistry. createAdmin must only be called once; subsequent calls raise InitializationException.
public ObjectPrx createAdmin(ObjectAdapter adminAdapter, Identity adminId)
Parameters
adminAdapterObjectAdapterThe object adapter used to host the Admin object; if null and Ice.Admin.Endpoints is set, create, activate and use the Ice.Admin object adapter.
adminIdIdentityThe identity of the Admin object.
Returns
- ObjectPrx
A proxy to the main ("") facet of the Admin object.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
createObjectAdapter(string, SslServerAuthenticationOptions?)
Creates a new object adapter. The endpoints for the object adapter are taken from the property
name.Endpoints.
It is legal to create an object adapter with the empty string as its name. Such an object
adapter is accessible via bidirectional connections or by collocated invocations.
public ObjectAdapter createObjectAdapter(string name, SslServerAuthenticationOptions? serverAuthenticationOptions = null)
Parameters
namestringThe object adapter name.
serverAuthenticationOptionsSslServerAuthenticationOptionsThe SSL options for server connections.
Returns
- ObjectAdapter
The new object adapter.
Exceptions
- InitializationException
Thrown when a named object adapter is created for which no configuration can be found.
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
createObjectAdapterWithEndpoints(string, string, SslServerAuthenticationOptions?)
Creates a new object adapter with endpoints. This method sets the property name.Endpoints,
and then calls createObjectAdapter(string, SslServerAuthenticationOptions?). It is provided as a convenience method.
Calling this method with an empty name will result in a UUID being generated for the name.
public ObjectAdapter createObjectAdapterWithEndpoints(string name, string endpoints, SslServerAuthenticationOptions? serverAuthenticationOptions = null)
Parameters
namestringThe object adapter name.
endpointsstringThe endpoints of the object adapter.
serverAuthenticationOptionsSslServerAuthenticationOptionsThe SSL options for server connections.
Returns
- ObjectAdapter
The new object adapter.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
createObjectAdapterWithRouter(string, RouterPrx)
Creates a new object adapter with a router. This method creates a routed object adapter. Calling this method with an empty name will result in a UUID being generated for the name.
public ObjectAdapter createObjectAdapterWithRouter(string name, RouterPrx router)
Parameters
Returns
- ObjectAdapter
The new object adapter.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
destroy()
Destroys this communicator. It's an alias for Dispose().
public void destroy()
findAdminFacet(string)
Returns a facet of the Admin object.
public Object? findAdminFacet(string facet)
Parameters
facetstringThe name of the Admin facet.
Returns
- Object
The servant associated with this Admin facet, or null if no facet is registered with the given name.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
findAllAdminFacets()
Returns a map of all facets of the Admin object.
public Dictionary<string, Object> findAllAdminFacets()
Returns
- Dictionary<string, Object>
A collection containing all the facet names and servants of the Admin object.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
flushBatchRequests(CompressBatch)
Flushes any pending batch requests for this communicator. This means all batch requests invoked on fixed proxies for all connections associated with the communicator. Any errors that occur while flushing a connection are ignored.
public void flushBatchRequests(CompressBatch compress)
Parameters
compressCompressBatchSpecifies whether or not the queued batch requests should be compressed before being sent over the wire.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
flushBatchRequestsAsync(CompressBatch, IProgress<bool>?, CancellationToken)
Flushes any pending batch requests for this communicator. This means all batch requests invoked on fixed proxies for all connections associated with the communicator. Any errors that occur while flushing a connection are ignored.
public Task flushBatchRequestsAsync(CompressBatch compress, IProgress<bool>? progress = null, CancellationToken cancel = default)
Parameters
compressCompressBatchSpecifies whether or not the queued batch requests should be compressed before being sent over the wire.
progressIProgress<bool>The sent progress provider.
cancelCancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task
A task that completes when the flush completes for all connections.
Exceptions
- CommunicatorDestroyedException
Thrown synchronously when the communicator has been destroyed.
getAdmin()
Gets a proxy to the main facet of the Admin object. getAdmin also creates the Admin object and creates and activates the Ice.Admin object adapter to host this Admin object if Ice.Admin.Endpoints is set. The identity of the Admin object created by getAdmin is {value of Ice.Admin.InstanceName}/admin, or {UUID}/admin when Ice.Admin.InstanceName is not set. If Ice.Admin.DelayCreation is 0 or not set, getAdmin is called by the communicator initialization, after initialization of all plugins.
public ObjectPrx? getAdmin()
Returns
- ObjectPrx
A proxy to the main ("") facet of the Admin object, or a null proxy if no Admin object is configured.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
getDefaultLocator()
Gets the default locator for this communicator.
public LocatorPrx? getDefaultLocator()
Returns
- LocatorPrx
The default locator for this communicator.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
getDefaultObjectAdapter()
Gets the object adapter that is associated by default with new outgoing connections created by this communicator. This method returns null unless you set a non-null default object adapter using setDefaultObjectAdapter(ObjectAdapter?).
public ObjectAdapter? getDefaultObjectAdapter()
Returns
- ObjectAdapter
The object adapter associated by default with new outgoing connections.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
- See Also
getDefaultRouter()
Gets the default router for this communicator.
public RouterPrx? getDefaultRouter()
Returns
- RouterPrx
The default router for this communicator.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
getImplicitContext()
Gets the implicit context associated with this communicator.
public ImplicitContext getImplicitContext()
Returns
- ImplicitContext
The implicit context associated with this communicator; returns null when the property Ice.ImplicitContext is not set or is set to None.
getLogger()
Gets the logger for this communicator.
public Logger getLogger()
Returns
- Logger
This communicator's logger.
getObserver()
Gets the observer resolver object for this communicator.
public CommunicatorObserver? getObserver()
Returns
- CommunicatorObserver
This communicator's observer resolver object.
getPluginManager()
Gets the plug-in manager for this communicator.
public PluginManager getPluginManager()
Returns
- PluginManager
This communicator's plug-in manager.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
getProperties()
Gets the properties for this communicator.
public Properties getProperties()
Returns
- Properties
This communicator's properties.
identityToString(Identity)
Converts an identity into a string.
public string identityToString(Identity ident)
Parameters
identIdentityThe identity to convert into a string.
Returns
- string
The "stringified" identity.
isShutdown()
Checks whether or not shutdown() was called on this communicator.
public bool isShutdown()
Returns
propertyToProxy(string)
Converts a set of proxy properties into a proxy. The "base" name supplied in the property
argument refers to a property containing a stringified proxy, such as MyProxy=id:tcp -h localhost -p 10000.
Additional properties configure local settings for the proxy.
public ObjectPrx? propertyToProxy(string property)
Parameters
propertystringThe base property name.
Returns
- ObjectPrx
The proxy, or
nullif the property is not set.
Exceptions
- ParseException
Thrown when the property value is not a valid proxy string.
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
proxyToProperty(ObjectPrx, string)
Converts a proxy into a set of proxy properties.
public Dictionary<string, string> proxyToProperty(ObjectPrx proxy, string prefix)
Parameters
Returns
- Dictionary<string, string>
The property set.
proxyToString(ObjectPrx?)
Converts a proxy into a string.
public string proxyToString(ObjectPrx? proxy)
Parameters
proxyObjectPrxThe proxy to convert into a stringified proxy.
Returns
- string
The stringified proxy, or an empty string if
proxyis null.
removeAdminFacet(string)
Removes a facet from the Admin object. Removing a facet that was not previously registered throws NotRegisteredException.
public Object removeAdminFacet(string facet)
Parameters
facetstringThe name of the Admin facet.
Returns
- Object
The servant associated with this Admin facet.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
setDefaultLocator(LocatorPrx?)
Sets a default Ice locator for this communicator. All newly created proxy and object adapters will use this default locator. To disable the default locator, null can be used. Note that this method has no effect on existing proxies or object adapters. You can also set a locator for an individual proxy by calling ice_locator(LocatorPrx?) on the proxy, or for an object adapter by calling setLocator(LocatorPrx?) on the object adapter.
public void setDefaultLocator(LocatorPrx? locator)
Parameters
locatorLocatorPrxThe default locator to use for this communicator.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
setDefaultObjectAdapter(ObjectAdapter?)
Sets the object adapter that will be associated with new outgoing connections created by this communicator. This method has no effect on existing outgoing connections, or on incoming connections.
public void setDefaultObjectAdapter(ObjectAdapter? adapter)
Parameters
adapterObjectAdapterThe object adapter to associate with new outgoing connections.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
- See Also
setDefaultRouter(RouterPrx?)
Sets a default router for this communicator. All newly created proxies will use this default router. To disable the default router, null can be used. Note that this method has no effect on existing proxies. You can also set a router for an individual proxy by calling ice_router(RouterPrx?) on the proxy.
public void setDefaultRouter(RouterPrx? router)
Parameters
routerRouterPrxThe default router to use for this communicator.
Exceptions
- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
shutdown()
Shuts down this communicator. This method calls deactivate() on all object adapters created by this communicator. Shutting down a communicator has no effect on outgoing connections.
public void shutdown()
- See Also
stringToProxy(string)
Converts a stringified proxy into a proxy.
public ObjectPrx? stringToProxy(string str)
Parameters
strstringThe stringified proxy to convert into a proxy.
Returns
- ObjectPrx
The proxy, or null if
stris an empty string.
Exceptions
- ParseException
Thrown when
stris not a valid proxy string.- CommunicatorDestroyedException
Thrown when the communicator has been destroyed.
waitForShutdown()
Waits for the shutdown of this communicator to complete. This method calls waitForDeactivate() on all object adapters created by this communicator. In a client application that does not accept incoming connections, this method returns as soon as another thread calls shutdown() or Dispose() on this communicator.
public void waitForShutdown()