Communicator Initialization and Destruction
Creating a Communicator
You create a communicator by calling Ice.initialize, for example:
import { Ice } from "@zeroc/ice";
await using communicator = Ice.initialize(process.argv);
This initialize
overload accepts the argument vector. The function scans the argument vector for any command-line options that are relevant to the Ice runtime; any such options are removed from the argument vector so, when initialize
returns, the only options and arguments remaining are those that concern your application. If anything goes wrong during initialization, initialize
throws an exception.
In a browser application, you should call the initialize
function without the argument vector.
Communicator
implements the asyncDispose
method. This allows you to create and cleanup your communicator with await using
as shown above.
Initialization Data
During the creation of a communicator, initialize
configures a number of features that affect the communicator's operation. Once set, these features remain in effect for the lifetime of the communicator, that is, you cannot change these features after you have created a communicator. Therefore, if you want to customize these features, you must do so when you create the communicator.
The InitializationData class or struct holds all the features (or options) that you can customize when you create a communicator.