Setting up Natural Access applications

Complete the following steps to set up a Natural Access application:

Step

Action

1

Initialize the Natural Access application.

2

Create event queues.

3

Create contexts.

4

Open services on each context.


Setting up a second Natural Access application

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.


Initializing Natural Access applications

Use ctaInitialize to initialize Natural Access applications. When you initialize Natural Access applications, you

Creating event queues

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.

Creating contexts

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:

If a server address is not specified in the context descriptor, the context is created on the default server as specified in cta.cfg.

Parameter management

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.