Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

VOS::Message Class Reference

This class handles storing, generating and parsing of the messages that are sent between virtual objects. More...

#include <vos/corelibs/vos/message.hh>

Inheritance diagram for VOS::Message:

VOS::RefCounted List of all members.

Public Member Functions

Public Attributes

Friends


Detailed Description

This class handles storing, generating and parsing of the messages that are sent between virtual objects.

Definition at line 50 of file message.hh.


Constructor & Destructor Documentation

Message::Message  ) 
 

Create a new message.

Definition at line 44 of file message.cc.

Message::Message Message m  ) 
 

Copy a message.

Definition at line 55 of file message.cc.

Message::~Message  ) 
 

Destroy this message.

Definition at line 70 of file message.cc.


Member Function Documentation

void Message::generateNonce  ) 
 

Have the message fill in the nonce field with a random nonce.

Definition at line 197 of file message.cc.

string Message::getDependency  ) 
 

Get the nonce of the OUTGOING REPLIES that this message depends on before it can be delivered, used to determine message context.

This is a comma-separeted no spaces!

Definition at line 190 of file message.cc.

const Message::Field & Message::getField int  n  )  throw (NoSuchFieldError)
 

Get the first field which matches the supplied key.

Note that this field list is SEPERATE from the type/to/from/method/nonce fields.

Parameters:
n the field at position n, where n is the array offset from 0.
Returns:
the first instance of a field which matchs that tag
Exceptions:
NoSuchFieldError if the field is not found

Definition at line 216 of file message.cc.

const Message::Field & Message::getField const string &  key  )  throw (NoSuchFieldError)
 

Get the first field which matches the supplied key.

Note that this field list is SEPERATE from the type/to/from/method/nonce fields.

Parameters:
key the tag to match
Returns:
the first instance of a field which matchs that tag
Exceptions:
NoSuchFieldError if the field is not found

Definition at line 204 of file message.cc.

const string & Message::getFormattedString bool  withLength = true  ) 
 

Get the message formatted with the function supplied in setMappingFunc().

Returns:
the formatted string

Definition at line 309 of file message.cc.

Referenced by VOS::MessageBlock::getString().

string Message::getFrom  )  const
 

Get the from field.

Returns:
the from field setFrom() has a bit more information about this field.

Definition at line 160 of file message.cc.

string Message::getLoggableString  ) 
 

Print out a string value for the message with substitutions done, to make it easier to tell what the processed message actually looked like.

Definition at line 315 of file message.cc.

MessageContext * Message::getMessageContext  ) 
 

Get the message block this message is contained in.

May be NULL.

Returns:
the message block; NOTE YOU MUST CALL release() WHEN DONE OR USE vRef.

Definition at line 183 of file message.cc.

string Message::getMethod  )  const
 

Get the method field.

Returns:
the method field setMethod() has a bit more information about this field.

Definition at line 165 of file message.cc.

string Message::getNonce  )  const
 

Get the nonce field.

Returns:
the nonce field setNonce() has a bit more information about this field.

Definition at line 171 of file message.cc.

int Message::getNumFields  )  const
 

Get the number of ordinary fields.

Returns:
the number of ordinary fields in this message

Definition at line 195 of file message.cc.

Site * Message::getSourceSite  ) 
 

Get the source site.

This is the site that actually generated this message. MAY BE ZERO IF THE MESSAGE WAS GENERATED LOCALLY. If so, you'll need to do the following to determine the source site: Site::findSite(URL(themsg.getFrom()).getHostAndPort())

Returns:
the source site, if any; NOTE YOU MUST CALL release() WHEN DONE OR USE vRef.

Definition at line 177 of file message.cc.

double Message::getTime  )  const
 

Get time field, used for scheduling.

Returns:
the time field. getTime() has a bit more information about this field.

Definition at line 176 of file message.cc.

string Message::getTo  )  const
 

Get the to field.

Returns:
the to field setTo() has a bit more information about this field.

Definition at line 155 of file message.cc.

const string & Message::getType  )  const
 

Returns:
the type field. setType() has a bit more information about this field.

Definition at line 170 of file message.cc.

bool Message::hasDependency  )  const
 

Get whether there is anything in the dependency field.

Returns:
if there is a dependency field setDependency() has a bit more information about this field.

Definition at line 150 of file message.cc.

bool Message::hasFrom  )  const
 

Get whether there is anything in the from field.

Returns:
if there is a from field setFrom() has a bit more information about this field.

Definition at line 135 of file message.cc.

bool Message::hasMethod  )  const
 

Get whether there is anything in the method field.

Returns:
if there is a method field setMethod() has a bit more information about this field.

Definition at line 140 of file message.cc.

bool Message::hasNonce  )  const
 

Get whether there is anything in the nonce field.

Returns:
if there is a nonce field setNonce() has a bit more information about this field.

Definition at line 145 of file message.cc.

bool Message::hasTo  )  const
 

Get whether there is anything in the to field.

Returns:
if there is a to field setTo() has a bit more information about this field.

Definition at line 130 of file message.cc.

void Message::insertField int  n,
const string &  key,
int  val
 

Insert a new field.

Note:
On positions: if a position is zero or positive, its meaning is as you would expect, expressing the offset into an array of fields. However, if the position is negative, it expresses the offset from the end of the list. This means for a list of length m, -1 is the last item in the list (equal to position position m - 1) and -m is the first item (equal to positive position 0). If the position is positive, the field is inserted such that it now occupies that position, and all fields starting from the previous occupant of that position onward are moved up one. If the position in negative, the field is similarly inserted so that it now occupies that position. For example, position -1 will append the field to the end of the list, position -2 will insert the field in the second-to-last position, etc.
Parameters:
n the position, as explained above
key the key (or tag) to associate the value with
val the value of this field

Definition at line 247 of file message.cc.

void Message::insertField int  n,
const string &  key,
double  val
 

Insert a new field.

Note:
On positions: if a position is zero or positive, its meaning is as you would expect, expressing the offset into an array of fields. However, if the position is negative, it expresses the offset from the end of the list. This means for a list of length m, -1 is the last item in the list (equal to position position m - 1) and -m is the first item (equal to positive position 0). If the position is positive, the field is inserted such that it now occupies that position, and all fields starting from the previous occupant of that position onward are moved up one. If the position in negative, the field is similarly inserted so that it now occupies that position. For example, position -1 will append the field to the end of the list, position -2 will insert the field in the second-to-last position, etc.
Parameters:
n the position, as explained above
key the key (or tag) to associate the value with
val the value of this field

Definition at line 262 of file message.cc.

void Message::insertField int  n,
const string &  key,
const string &  val,
bool  quoted = false
 

Insert a new field.

Note:
On positions: if a position is zero or positive, its meaning is as you would expect, expressing the offset into an array of fields. However, if the position is negative, it expresses the offset from the end of the list. This means for a list of length m, -1 is the last item in the list (equal to position position m - 1) and -m is the first item (equal to positive position 0). If the position is positive, the field is inserted such that it now occupies that position, and all fields starting from the previous occupant of that position onward are moved up one. If the position in negative, the field is similarly inserted so that it now occupies that position. For example, position -1 will append the field to the end of the list, position -2 will insert the field in the second-to-last position, etc.
Parameters:
n the position, as explained above
key the key (or tag) to associate the value with
val the value of this field
whether this field is "quoted", eg suppress substition

Definition at line 226 of file message.cc.

void Message::removeField const string &  s  ) 
 

Remove the first instance of a field with the supplied key.

Parameters:
s the key of the field to remove

Definition at line 283 of file message.cc.

void Message::removeField int  n  ) 
 

Remove an existing field at some position.

See insertField() for details about the legal numerical values of the position.

Parameters:
n the position

Definition at line 276 of file message.cc.

void Message::setDependency const string &  nonce  ) 
 

Definition at line 125 of file message.cc.

void Message::setFrom const string &  s  ) 
 

Set whom this message is sent by.

This should probably be the URL string of the object which is generating this message.

Parameters:
s the from field

Definition at line 111 of file message.cc.

void Message::setMappingFunc string *(*  func)(const string &type, const string &to, const string &from, const string &method, const string &nonce, const string &dependsOn, double mtime, const deque< Message::Field > &fields, bool withLength)  ) 
 

Set the function which converts this message structure into a string.

End users don't need to call this, as it is set to the default when the message is constructed.

Note:
The more object-oriented way of doing this would be to create a function object type. This interface may change.

Definition at line 295 of file message.cc.

Referenced by Message().

void Message::setMessageContext MessageContext mb  ) 
 

Indicate the message block this message is contained in.

Does not actually add itself to the message block, however (you really want to be using MessageBlock::insertMessage())

Parameters:
mb the message block

Definition at line 120 of file message.cc.

void Message::setMethod const string &  s  ) 
 

Set the method action this message is expressing.

Parameters:
s the method field

Definition at line 112 of file message.cc.

void Message::setNonce const string &  s  ) 
 

Set the nonce field.

The nonce is used to match a match a reply against a request (because the reply bears the same nonce as the originating message.)

Parameters:
s the nonce field

Definition at line 113 of file message.cc.

Referenced by generateNonce().

void Message::setSourceSite Site source_site  ) 
 

Set the source site.

This is not a field in the message itself, but rather is used to set the site originating this message (that is to say, which socket the message was received on.) This is compared against the "from" field to provide a simple filter against really obvious spoofing. You do NOT need to set this if you are creating a new message to be sent; it is only used for messages received from the network.

Parameters:
s the source site

Definition at line 115 of file message.cc.

Referenced by VOS::RemoteStreamSite::runScript().

void Message::setTime double  time  ) 
 

Set the time field, in seconds.

This is used by the message delivery scheduler to determine when to deliver this message, useful for scripted events in MessageBlock objects.

Parameters:
time the time field

Definition at line 114 of file message.cc.

void Message::setTo const string &  s  ) 
 

Set whom this message is intended for.

This should probably be the URL string of the object to which the message is destined.

Parameters:
s the to field

Definition at line 109 of file message.cc.

void Message::setType const string &  s  ) 
 

Set what type of message this is.

You probably want it to be either "message" or "update".

Parameters:
s the types

Definition at line 110 of file message.cc.


Friends And Related Function Documentation

int msgFlexLexer::yylex  )  [friend]
 

Internal debugging function.


Member Data Documentation

int VOS::Message::incoming_debug
 

Definition at line 99 of file message.hh.

Referenced by Message().

int VOS::Message::refcount_debug
 

Definition at line 98 of file message.hh.

Referenced by Message(), and ~Message().


The documentation for this class was generated from the following files:
Generated on Tue Aug 12 03:56:04 2003 for Interreality Project - VOS by doxygen 1.3.2