Main Page | Data Structures | File List | Data Fields | Globals

messages.c File Reference

Server message handling functions. More...

#include "isisserver.h"

Functions

void handleMessage (int sendHost, int destHost, char *msgBody)
 Handle messages received by the ISIS server.
void broadcastMessage (int sendHost, char *msgBody)
 Broadcast a message to all clients.
void sendMessage (int destHost, char *message)
 Send a message string to a client.


Detailed Description

Server message handling functions.

The ISIS server passes messages between clients using the ICIMACS Messaging Protocol version 2 (IMPv2).

... more to come ...


Function Documentation

void handleMessage int  sendHost,
int  destHost,
char *  msgBody
 

Handle messages received by the ISIS server.

Parameters:
sendHost Client table index of the sending client host
destHost Client table index of the destination host
msgBody Body of the message
Figures out what to do with a message received and already validated by the calling procedure. There are three possibilities:
  1. It is an ISIS server command request to be passed to isisCommand() for processing.
  2. It is a broadcast message to be copied out to all known ISIS client hosts (passed to broadcastMessage()), as well as being processed by the server proper (passed to isisCommand()).
  3. It is a message to be routed to another client host using sendMessage().
This routine is designed to be safe for future multithreading.

IMPv2 messages are terminated with return (\r = ASCII 13), not with a newline (\n = ASCII 10). Messages prepared for further routing by sendMessage() must be correctly terminated. Those printed to stdout do not require termination, as the printing routine will strip any termination and provide a \r as required.

BEWARE: No terminination checking is done by sendMessage()!

void broadcastMessage int  sendHost,
char *  msgBody
 

Broadcast a message to all clients.

Parameters:
sendHost Client table index of the sending host
msgBody Body of the broadcast message.
Sends a broadcast message out to all known clients on the system. Broadcast messages take the form of
 XX>AL message_text\r 
If XX is the local host, we pass it to all ports in this order:
  1. to each active serial port
  2. to each active network client
If XX is one of our known clients, we pass the message along only to ports other than the one the sending client is using.

This is a key distinction: broadcasts are blind-sent to ports not hosts. We have to be careful not to echo a broadcast back to the sender, which risks starting infinite regressions.

Designed to be lightweight and thread safe. All routines called by this (and the routine itself) must not alter global variables. this means that logging is the responsibility of calling programs upstream.

void sendMessage int  destHost,
char *  message
 

Send a message string to a client.

Parameters:
destHost Index of the destination client host in the server's client table
message The message to send
Sends the message to a client. The message must by this point be in the form of a valid IMPv2 protocol message:
 XX>YY message_text\r 
for passing. The transport mechanism is based on the entries for destHost in the client host table. This presumes that the calling routine has already validated the destination host as valid.

The message must be properly terminated with \r (ASCII 13) as per the IMPv2 message format specification.

Designed to be lightweight and thread safe. All routines called by this (and the routine itself) must not alter global variables. this means that logging is the responsibility of calling programs upstream.


Generated on Tue Apr 16 17:04:08 2013 for ISIS Server by  doxygen 1.3.9.1