VRPN 06.04

VRPN main page

Obtaining VRPN

VRPN Support

Installing and Testing

Compiling and Modifying

Client code

Server code

Troubleshooting

Connections

Logging and Playback

Shared Objects

Sound

Clock Synchronization

Text Messages

Doxygen documentation

VRPN on PDAs

Coming attractions & suggestions

UNC-specific information

Registering a sender

The sender field in a message specifies the name of the device that is sending or that is to receive the message. This can be thought of as a channel descriptor. Senders are defined to a vrpn_Connection by a string name; the connection reports a token (a long integer) that is to be used to refer to that sender when sending and receiving messages. Examples of senders might be, "Tracker0@ioglab.cs.unc.edu" and "Button0@ioglab.cs.unc.edu". A device can get a token for a given sender name by calling:

long vrpn_Connection::register_sender(char *name);

For example, a program could open a listening connection and then describe a new sender called "Test0@ioglab.cs.unc.edu" by doing the following:

	vrpn_Connection *connection = new vrpn_Connection();
	long my_id = connection->register_sender("Test0@ioglab.cs.unc.edu");

The identifier my_id could then be used as the sender field to send a message or to register a message handler.

Each vrpn_Connection object maintains a list of senders that have been registered with it. When a link is established between two connections, each describes its mapping from strings to tokens to the other. Each vrpn_Connection maintains a table that it uses to translate the sender field coming across the link into its local value before delivering the message. This allows each connection object to allocate its own list of sender-to-token mappings independently.

This string-to-token mapping is done for two efficiency reasons. Firstly, it allows the connection to avoid doing string-matching to determine what to do with a given message. Second, it reduces the bandwidth sent over the link between connections (for names longer than 4 characters). Strings are used to give the device classes and user code flexibility in defining senders.