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

  • From: Marius Kjeldahl <marius@xxxxxxxxxxxx>
  • To: muscle@xxxxxxxxxxxxx
  • Date: Thu, 11 Dec 2003 12:27:22 +0100

I've dug further into this, and it seems (as mentioned in the FRC game sample 
article) that BroadcastToAllSessions currently is the proper method to use 
for doing this after all. I had a look at the code, and it is very simple:

AbstractReflectSession ::
BroadcastToAllSessions(MessageRef msgRef, void * userData, bool toSelf)
   HashtableIterator<const char *, AbstractReflectSessionRef> iter = 
   AbstractReflectSessionRef * next;
   while((next = iter.GetNextValue()) != NULL)
      AbstractReflectSession * session = next->GetItemPointer();
      if ((session)&&((toSelf)||(session != this))) 
session->MessageReceivedFromSession(*this, msgRef, userData);

By simply having the PlayerSession ignore the "MessageReceivedFromSession" 
calls (which is the default behaviour AFAIK) and only having the GameState 
session picking them up, it sortof acts like a "direct message" to the 
GameState session.

When/if the "broadcast" method becomes a bottleneck, it should be fairly 
simple to reimplement this functionality of only sending to a destination 
session and probably implementing a random access method for finding 


Marius K.

On Wednesday 10 December 2003 13:20, you wrote:
> I have clients connected to a server. Each client is able to update their
> own subtrees in the database. For authentication purposes (and probably
> other state stuff that I want to keep server side), I want the server to be
> able to write into its own subtrees in the database ("gamestate" tree).
> When a client sends some infomation this is received by the corresponding
> StorageReflectSession subclass server side. Depending on how that
> information was treated, I want to store information in another
> StorageReflectSession subclass (typically the one instance holding the
> common gamestate).
> So, in short, after processing some data from the client in a "player"
> subclass of StorageReflectSession subclass, I want to send a message to the
> "gamestate" subclass of StorageReflectSession.
> Unfortunately, I have not found an easy way to do this. I have looked at
> the SendMessageToSessions method found in the MessageTransceiverThread
> class (and subclasses), but on the server I have no explicit instance of
> any message transceiver class. I have not found any easy way to get to one
> either from StorageReflectSession.
> So what am I missing? Is there any easy way to send messages from one
> server side session to another?
> Thanks,
> Marius Kjeldahl

Other related posts: