# Using aliases

The Natural Access dispatcher enables provider services to associate aliases with their events in the RTC database. A consumer service can register actions to be taken whenever the dispatcher receives an event associated with a given alias.

This topic presents:

- Overview of using aliases

- Program flow

## Overview of using aliases

The provider service creates the alias and event association in the database. Multiple services can associate different events with the same alias:

Adding aliases to RTC database

To receive RTC notification whenever an event in the alias group occurs, a consumer service uses dispAddRTC to register the alias as a condition and associate an action with it:

Registering an RTC action based on an alias

When an event associated with an alias occurs, the dispatcher notifies any consumer services registered with the alias:

Action performed in response to aliased event

Using of aliases has the following advantages:

- Instead of registering several times for different events, a consumer service can register one time to be notified whenever any event occurs that indicates a certain state or occurrence.

- Some services generate different events indicating the same occurrence. If these events are both listed under the same alias, a registered consumer service can be alerted to an event without needing to know which service generated the event, or without having to register both events.

- Event names can change, and new event names can be added to an alias without changes to the consumer services.

  Note: Some Natural Access base services register aliases when they are opened on a context. For a list of these aliases and associated events, refer to Natural Access base services RTC aliases.

## Program flow

The provider service uses dispRegisterRTCAlias to create the alias and event association in the database. Each successful invocation of dispRegisterRTCAlias adds one alias and event association to the RTC database. The service manager can add as many as necessary. It can also add multiple events to the same alias. Alias names do not need to be unique between service providers.

Provider service managers can add aliases using dispRegisterRTCAlias at any time. Typically, however, this task is performed when the service is opened (the dispatcher invokes xxxOpenService). If aliases are added at this time, the aliases are also typically removed when xxxCloseService is invoked (using the dispatcher function dispUnregisterRTCAlias).

To register an action to take when a provider service generates an event associated with a given alias, a consumer service invokes dispAddRTC. With this function, the service manager passes pointers to structures specifying the alias as the condition, and a corresponding action command.

When a provider service has created an alias and event association in the database, and at least one consumer service has invoked dispAddRTC to associate an action with the alias, the dispatcher invokes the provider service's xxxAddRTC command. The alias is passed back with the command:

Command flow: registering aliases

Consumer services can associate actions with a given alias even before the provider service has created it using dispRegisterRTCAlias. In either case, the provider service receives xxxAddRTC only after it has created the alias and at least one consumer service has requested RTC notification based on the alias:

xxxAddRTC returned only after request for RTC notification

When the provider service generates an event, the dispatcher consults its database. If the event is associated with an alias, the dispatcher sends action commands to any consumer services that registered to be notified:

Action sent in response to event with alias