Sessions
Multiple sessions are allowed by the API, although typical scenarios will need only one session. Other scenarios, such as an IG controlled by
multiple hosts, will require multiple sessions.
Refer to the diagram below for a depiction of an IG that is driven by two hosts, a cockpit and a threat server. In this example,
the threat server is connected to a DIS/HLA network providing combat environment data to the IG, including the movements of other simulator
hosts on the network. In this distributed combat arena scenario, the IG would need two sessions - one to talk to the cockpit and one for the
threat server.
|
Figure 3 - A Multiple Session IG |
Creating a Session
The prototype for creating a session is as follows.
Example |
int CigiCreateSession(
const int type,
const int numbuffers,
const int buffersize
);
|
|
|
The type argument indicates if the session created is for a host or an IG. For a host session, the value should be
CIGI_HOST_SESSION , and for an IG it should be CIGI_IG_SESSION .
The numbuffers argument specifies how many buffers to create for holding packets. When a message is sent, only one buffer is sent at
a time. Any data that does not fit into the buffer that will be sent out as the next message will be queued up in the back buffers, if there
is room available.
The buffersize argument indicates the size of each buffer, and the size of the message that will be sent out each time a start-of-frame
packet is received. Thus the total amount of buffer space available is equal to the buffersize times the number of buffers.
Session Example
The example below creates a CIGI host session, created with 4 buffers each of size 1024 bytes.
Example |
CigiCreateSession( CIGI_HOST_SESSION, 4, 1024);
|
|
|
The total buffer size is the number of buffers times the buffer size, so in this example, 4 buffers of size 1024 are created, giving a total
buffer size of 4096. The following figure shows the contents of the session. Notice that the buffers are initialized as empty and, that the
space at the beginning if each buffer is marked as reserved. The first portion of the buffers is reserved for the CIGI_IG_CONTROL
packet for host sessions, because the interfaces states that this will always be the first packet in a message. For more information on adding
packets, refer to the section on messages
|
Figure 4 - Creating a CIGI Session |
The variables listed on the left-hand side of the figure, pointing to the buffer are internal to the CIGI API, and are not relevant to this
discussion. For more information about internal session variables, see the section in implementation notes.
|
|