[muscle] Re: Updating the message storage database server side

  • From: "Jeremy Friesner" <jaf@xxxxxxxxxxxx>
  • To: muscle@xxxxxxxxxxxxx
  • Date: Wed, 10 Dec 2003 09:06:08 PST (-0800)

Hi Marius,

> So what am I missing=3F Is there any easy way to send messages from one 
> server 
> side session to another=3F

There are several ways to do this, found in the ServerComponent API (of which
StorageReflectSession is a subclass).   One easy way is to call 
SendMessageToMatchingSessions(),
using a node-path string that matches only the session you want to receive the 
Message:

// Send myMsgRef only to session #0, i.e. the first session the server 
instantiated
SendMessageToMatchingSessions(myMsgRef, "/*/0", QueryFilterRef(), false);

Or, you can do the same thing "by hand" (and somewhat more efficiently), by 
obtaining 
a pointer or reference to the session you wish to send the Message to, and then 
directly
calling MessageReceivedFromSession(*this, msgRef, NULL) on that session.

For example:

AbstractReflectSession gameStateRef =3D GetSession("0");  // get ref to first 
instantiated session
if (gameStateRef()) gameStateRef()->MessageReceivedFromSession(*this, myMsgRef, 
NULL);

or

HashtableIterator<const char *, AbstractReflectSessionRef> iter =3D 
GetSessions();
const char * nextKey;
AbstractReflectSessionRef nextSessionRef;
while(iter.GetNextKeyAndValue(nextKey, nextSessionRef) =3D=3D B=5FNO=5FERROR)
{
   if (your=5Fcriteria=5Fhere) 
nextSessionRef()->MessageReceivedFromSession(*this, myMsgRef, NULL);
}

-Jeremy


Other related posts: