Complete the following steps to set up a Natural Access application:
Step |
Action |
1 |
|
2 |
|
3 |
|
4 |
Open services on each context. |
Complete the following steps to set up a second Natural Access application that shares a context with the first application:
Step |
Action |
1 |
Initialize the Natural Access application. |
2 |
Create event queues. |
3 |
Attach to the existing context that the applications will share. |
Use ctaInitialize to initialize Natural Access applications. When you initialize Natural Access applications, you
Register the services that are available to the application.
Specify the parameter management strategy.
Enable or disable tracing.
Enable or disable the wait object notification event when the internal wait object list has changed.
Call ctaCreateQueue to create one or more event queues. Specify the service managers to attach to each queue (if this is different than the defaults specified in the cta.cfg file). When you attach or bind a service manager to a queue, you make the service manager available to the queue. After the services are opened, the events generated by the managed services go to the attached queue.
ctaCreateQueue returns an event queue handle (ctaqueuehd) that addresses the event queue. You supply the handle to retrieve events from the queue when calling ctaWaitEvent.
Applications can invoke ctaCreateQueue multiple times within a single process. Each invocation returns a unique queue handle.
After creating the event queue, Natural Access knows which services are available to the event queue (specified by the service managers). You can now create contexts on the event queue.
To create contexts, call ctaCreateContext (or ctaCreateContextEx for shared contexts) and provide the queue handle (ctaqueuehd) that ctaCreateQueue returned. All events for services on the context are received in the specified event queue. ctaCreateContext returns a context handle (ctahd), which the application uses when invoking Natural Access functions. Events communicated back to the application are also associated with the context.
When creating a context, you can specify the following information:
Context descriptor (descriptor). Descriptor defines each context by associating a context name and (optionally) the address of the server on which the context is created. To implement shared contexts, specify the context descriptor as a parameter when invoking ctaCreateContext or ctaCreateContextEx.
If a server address is not specified in the context descriptor, the context is created on the default server as specified in cta.cfg.
User-defined value (userid). Natural Access never interprets userid. The value is echoed back to the application in the event structure when events are delivered. It can be used (instead of the ctahd) to correlate the context with an application-specific data structure.
The server on which to create the context. If you do not specify a server, the context is created on the default Natural Access Server.
Natural Access manages parameters for services on a context basis. The context maintains a copy of the parameters for all services managed by the dispatcher and specified in the call to ctaInitialize. Parameters can be modified for a service not yet opened by ctaOpenServices as long as the service is registered in the call to ctaInitialize. This feature gives applications the flexibility to open and close services without affecting context parameter values. Refer to Opening services for more information.