ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | List of all members
ZGDatabasePeerSession Class Referenceabstract

This is a convenience class; it is the same as a ZGPeerSession except that it also knows how to create and manage some user-provided IDatabaseObjects (one per database) so that the subclass doesn't have to implement all of the Message<->IDatabaseObject plumbing manually. More...

#include <ZGDatabasePeerSession.h>

Inheritance diagram for ZGDatabasePeerSession:
Inheritance graph
[legend]

Public Member Functions

 ZGDatabasePeerSession (const ZGPeerSettings &peerSettings)
 Constructor. More...
 
virtual status_t AttachedToServer ()
 Overridden to create and set up our IDatabaseObjects. More...
 
IDatabaseObjectGetDatabaseObject (uint32 whichDatabase)
 Convenience method: Returns a read/write pointer to the specified IDatabaseObject that we hold. More...
 
const IDatabaseObjectGetDatabaseObject (uint32 whichDatabase) const
 Convenience method: Returns a read-only pointer to the specified IDatabaseObject that we hold. More...
 
virtual void AboutToDetachFromServer ()
 Called just before this session object is detached from the ReflectServer object. More...
 
virtual void EndSession ()
 Call this to request the termination of this session and its detachment from the ReflectServer. More...
 
virtual uint64 GetPulseTime (const PulseArgs &args)
 Returns the time (in microseconds, using the timebase of GetRunTime64()) when Pulse() should next be called. More...
 
virtual void Pulse (const PulseArgs &args)
 Called at (approximately) the time specified by GetPulseTime(). More...
 
virtual bool IsReadyForTextCommands () const
 Default implementation returns true iff we are currently fully attached to the ZG system. More...
 
virtual bool TextCommandReceived (const String &text)
 Default implementation handles some standard ZG commands such as "print peers" or "print sessions". More...
 
bool IAmTheSeniorPeer () const
 Returns true iff this peer is currently considered to be the senior peer of the system. More...
 
const ZGPeerSettingsGetPeerSettings () const
 Returns the ZGPeerSettings object, as passed to our constructor. More...
 
virtual void NetworkInterfacesChanged (const Hashtable< String, Void > &optInterfaceNames)
 Called when the set of available network interfaces on this computer has changed. More...
 
virtual void ComputerIsAboutToSleep ()
 Called just before this computer goes to sleep (e.g. More...
 
virtual void ComputerJustWokeUp ()
 Called just after this computer woke up from sleep (e.g. More...
 
bool IAmFullyAttached () const
 Returns true iff this peer is fully attached to the system (i.e. More...
 
virtual void LocalSeniorPeerStatusChanged ()
 Called whenever this peer has gained or lost senior-peer status (current status is indicated by the return value of IAmTheSeniorPeer()) More...
 
const ZGPeerIDGetLocalPeerID () const
 Returns the ZGPeerID being used by this local peer. More...
 
const ZGPeerIDGetSeniorPeerID () const
 Returns the ZGPeerID of the senior peer of this system, or an invalid ZGPeerID if there currently is no senior peer (that we know of). More...
 
virtual uint64 GetNetworkTime64 () const
 Returns the current time according to the network-time-clock, in microseconds. More...
 
virtual uint64 GetRunTime64ForNetworkTime64 (uint64 networkTime64TimeStamp) const
 Given a network-time-clock-value (i.e. More...
 
virtual uint64 GetNetworkTime64ForRunTime64 (uint64 runTime64TimeStamp) const
 Given a local-time-clock-value (i.e. More...
 
virtual int64 GetToNetworkTimeOffset () const
 Returns the number of microseconds that should be added to a GetRunTime64() value to turn it into a GetNetworkTime64() value, or subtracted to do the inverse operation. More...
 
const Hashtable< ZGPeerID,
ConstMessageRef > & 
GetOnlinePeers () const
 Returns a reference to a read-only table of the peers that are currently online in the system. More...
 
bool IsPeerOnline (const ZGPeerID &peerID) const
 Returns true iff if the specified peer is currently online. More...
 
uint64 GetEstimatedLatencyToPeer (const ZGPeerID &peerID) const
 Gets our current estimate of the one-way network latency between us and the specified peer. More...
 

Protected Member Functions

virtual IDatabaseObjectRef CreateDatabaseObject (uint32 whichDatabase)=0
 This will be called as part of the startup sequence. More...
 
virtual void ResetLocalDatabaseToDefault (uint32 whichDatabase, uint32 &dbChecksum)
 Must be implemented to reset local state of the specified database to its well-known default state. More...
 
virtual ConstMessageRef SeniorUpdateLocalDatabase (uint32 whichDatabase, uint32 &dbChecksum, const ConstMessageRef &seniorDoMsg)
 This method will only be called on the senior peer. More...
 
virtual status_t JuniorUpdateLocalDatabase (uint32 whichDatabase, uint32 &dbChecksum, const ConstMessageRef &juniorDoMsg)
 This method will only be called on junior peers. More...
 
virtual MessageRef SaveLocalDatabaseToMessage (uint32 whichDatabase) const
 This method should be implemented to save the state of the specified local database into a Message. More...
 
virtual status_t SetLocalDatabaseFromMessage (uint32 whichDatabase, uint32 &dbChecksum, const ConstMessageRef &newDBStateMsg)
 This method should be implemented to replace the current state of the specified local database with the new state represented by the passed-in Message. More...
 
virtual uint32 CalculateLocalDatabaseChecksum (uint32 whichDatabase) const
 This method is used for sanity-checking. More...
 
virtual String GetLocalDatabaseContentsAsString (uint32 whichDatabase) const
 This method may be implemented to return a human-readable representation of the specified database's current contents as a String. More...
 
status_t RequestResetDatabaseStateToDefault (uint32 whichDatabase)
 Call this if you want to request that the specified database be reset back to its well-known default state. More...
 
status_t RequestReplaceDatabaseState (uint32 whichDatabase, const MessageRef &newDatabaseStateMsg)
 Call this if you want to request that the specified database be completely replaced with a new state that is specified by the passed-in Message. More...
 
status_t RequestUpdateDatabaseState (uint32 whichDatabase, const MessageRef &databaseUpdateMsg)
 Call this if you want to request that the specified database be incrementally updated to a new state via a specified passed-in Message. More...
 
virtual void MessageReceivedFromGateway (const MessageRef &msg, void *userData)
 Implemented as a no-op, since by default this session doesn't have a gateway. More...
 
virtual void PeerHasComeOnline (const ZGPeerID &peerID, const ConstMessageRef &peerInfo)
 Called when a new peer has joined our group. More...
 
virtual void PeerHasGoneOffline (const ZGPeerID &peerID, const ConstMessageRef &peerInfo)
 Called when a peer has left our group. More...
 
virtual void SeniorPeerChanged (const ZGPeerID &oldSeniorPeerID, const ZGPeerID &newSeniorPeerID)
 Called when the senior peer of our peer group has changed. More...
 
status_t SendMulticastUserMessageToAllPeers (const MessageRef &msg)
 Tries to send the given Message to all peers (except this one) via UDP multicast. More...
 
status_t SendUnicastUserMessageToAllPeers (const MessageRef &msg)
 Tries to send the given Message to all peers (except this one) via multiple instances of TCP unicast. More...
 
status_t SendUnicastUserMessageToPeer (const ZGPeerID &destinationPeerID, const MessageRef &msg)
 Tries to send the given Message to a specific peers via TCP unicast. More...
 
void PrintDatabaseStateInfo (int32 whichDatabase=-1) const
 Prints various database-state information to stdout. More...
 
void PrintDatabaseUpdateLog (int32 whichDatabase=-1) const
 Prints the database update-log(s) to stdout. More...
 
bool ParseGenericTextCommand (const String &cmd)
 Tries to handle any text commands that can be handled generically; that is, any commands that can be handled without knowing anything about this particular application. More...
 

Detailed Description

This is a convenience class; it is the same as a ZGPeerSession except that it also knows how to create and manage some user-provided IDatabaseObjects (one per database) so that the subclass doesn't have to implement all of the Message<->IDatabaseObject plumbing manually.

Definition at line 14 of file ZGDatabasePeerSession.h.

Constructor & Destructor Documentation

ZGDatabasePeerSession ( const ZGPeerSettings peerSettings)

Constructor.

Parameters
peerSettingsthe ZGPeerSettings that this system is to use.

Member Function Documentation

virtual void AboutToDetachFromServer ( )
virtualinherited

Called just before this session object is detached from the ReflectServer object.

virtual status_t AttachedToServer ( )
virtual

Overridden to create and set up our IDatabaseObjects.

Reimplemented from ZGPeerSession.

virtual uint32 CalculateLocalDatabaseChecksum ( uint32  whichDatabase) const
protectedvirtual

This method is used for sanity-checking.

It should be implemented to scan the specified local database and return a checksum representing all of the data in the database. This checksum should match the checksums returned/updated by the SeniorUpdateLocalDatabase() and JuniorUpdateLocalDatabase() functions for the same database state.

Implements ZGPeerSession.

virtual void ComputerIsAboutToSleep ( )
inlinevirtualinherited

Called just before this computer goes to sleep (e.g.

due to closing a laptop lid)

Definition at line 83 of file ZGPeerSession.h.

virtual void ComputerJustWokeUp ( )
inlinevirtualinherited

Called just after this computer woke up from sleep (e.g.

due to opening a laptop lid)

Definition at line 86 of file ZGPeerSession.h.

virtual IDatabaseObjectRef CreateDatabaseObject ( uint32  whichDatabase)
protectedpure virtual

This will be called as part of the startup sequence.

It should create a new IDatabaseObject that will represent the specified database and return a reference to it, for the ZGDatabasePeerSession to manage.

Parameters
whichDatabaseThe index of the database that we need an object to represent.

Implemented in ChoirSession.

virtual void EndSession ( )
virtualinherited

Call this to request the termination of this session and its detachment from the ReflectServer.

Overridden to do some thread-shutdown work to avoid race conditions.

IDatabaseObject* GetDatabaseObject ( uint32  whichDatabase)
inline

Convenience method: Returns a read/write pointer to the specified IDatabaseObject that we hold.

Parameters
whichDatabaseThe index of the database that we need an object to represent.

Definition at line 28 of file ZGDatabasePeerSession.h.

const IDatabaseObject* GetDatabaseObject ( uint32  whichDatabase) const
inline

Convenience method: Returns a read-only pointer to the specified IDatabaseObject that we hold.

Parameters
whichDatabaseThe index of the database that we need an object to represent.

Definition at line 33 of file ZGDatabasePeerSession.h.

uint64 GetEstimatedLatencyToPeer ( const ZGPeerID peerID) const
inherited

Gets our current estimate of the one-way network latency between us and the specified peer.

Parameters
peerIDThe peer ID to get the latency of
Returns
The estimated latency, in microseconds, or MUSCLE_TIME_NEVER if the latency is unknown.
virtual String GetLocalDatabaseContentsAsString ( uint32  whichDatabase) const
protectedvirtual

This method may be implemented to return a human-readable representation of the specified database's current contents as a String.

This string will be printed to stdout after a checksum error has occurred, to make it easier to debug the update logic (i.e. by comparing the database state before and after the checksum-mismatched database was replaced, to see what is different). The default implementation of this method just returns "(GetLocalDatabaseContentsAsString unimplemented)".

Parameters
whichDatabaseThe index of the database to return a string for.

Reimplemented from ZGPeerSession.

const ZGPeerID& GetLocalPeerID ( ) const
inlineinherited

Returns the ZGPeerID being used by this local peer.

Returned value is not valid until after ZGPeerSession::AttachedToServer() returns B_NO_ERROR.

Definition at line 95 of file ZGPeerSession.h.

virtual uint64 GetNetworkTime64 ( ) const
inlinevirtualinherited

Returns the current time according to the network-time-clock, in microseconds.

The intent of this clock is to be the same on all peers in the system. However, this means that it may occasionally change (break monotonicity) in order to synchronize with the other peers in the system. Note that this function will return 0 if we aren't currently fully attached to the system, since before then we don't know the network time.

Implements INetworkTimeProvider.

Definition at line 105 of file ZGPeerSession.h.

References ZGPeerSession::GetNetworkTime64ForRunTime64().

virtual uint64 GetNetworkTime64ForRunTime64 ( uint64  runTime64TimeStamp) const
inlinevirtualinherited

Given a local-time-clock-value (i.e.

one using the same time-base as returned by GetRunTime64()), returns the approximately equivalent network-time-value (i.e. one using the same time-base as returned by GetNetworkTime64())

Implements INetworkTimeProvider.

Definition at line 115 of file ZGPeerSession.h.

References ZGPeerSession::GetToNetworkTimeOffset().

Referenced by ZGPeerSession::GetNetworkTime64().

const Hashtable<ZGPeerID, ConstMessageRef>& GetOnlinePeers ( ) const
inlineinherited

Returns a reference to a read-only table of the peers that are currently online in the system.

The keys in the table are the peer's IDs, and the values are the peers' attributes (may be NULL if they didn't advertise any) The ordering of the entries in the table is not significant (in particular, it doesn't reflect the ordering of the peers' seniority, at least not for now).

Definition at line 126 of file ZGPeerSession.h.

const ZGPeerSettings& GetPeerSettings ( ) const
inlineinherited

Returns the ZGPeerSettings object, as passed to our constructor.

Definition at line 73 of file ZGPeerSession.h.

virtual uint64 GetPulseTime ( const PulseArgs &  args)
virtualinherited

Returns the time (in microseconds, using the timebase of GetRunTime64()) when Pulse() should next be called.

Parameters
argsContext information for this call (including the current time and the time at which Pulse() was supposed to be called at)
Returns
a new time in microseconds, or MUSCLE_TIME_NEVER if we don't need Pulse() to be called.

Reimplemented in ChoirSession.

virtual uint64 GetRunTime64ForNetworkTime64 ( uint64  networkTime64TimeStamp) const
inlinevirtualinherited

Given a network-time-clock-value (i.e.

one using the same time-base as returned by GetNetworkTime64()), returns the approximately-equivalent local-time-clock-value (i.e. one using the same time-base as returned by GetRunTime64())

Implements INetworkTimeProvider.

Definition at line 110 of file ZGPeerSession.h.

References ZGPeerSession::GetToNetworkTimeOffset().

const ZGPeerID& GetSeniorPeerID ( ) const
inlineinherited

Returns the ZGPeerID of the senior peer of this system, or an invalid ZGPeerID if there currently is no senior peer (that we know of).

Definition at line 98 of file ZGPeerSession.h.

virtual int64 GetToNetworkTimeOffset ( ) const
virtualinherited

Returns the number of microseconds that should be added to a GetRunTime64() value to turn it into a GetNetworkTime64() value, or subtracted to do the inverse operation.

Note that this value will vary from one moment to the next!

Implements INetworkTimeProvider.

Referenced by ZGPeerSession::GetNetworkTime64ForRunTime64(), and ZGPeerSession::GetRunTime64ForNetworkTime64().

bool IAmFullyAttached ( ) const
inlineinherited

Returns true iff this peer is fully attached to the system (i.e.

has completed enumeration of which other peers are online, etc)

Definition at line 89 of file ZGPeerSession.h.

bool IAmTheSeniorPeer ( ) const
inherited

Returns true iff this peer is currently considered to be the senior peer of the system.

bool IsPeerOnline ( const ZGPeerID peerID) const
inherited

Returns true iff if the specified peer is currently online.

Parameters
peerIDThe peer ID to check on.
virtual bool IsReadyForTextCommands ( ) const
inlinevirtualinherited

Default implementation returns true iff we are currently fully attached to the ZG system.

Implements ITextCommandReceiver.

Definition at line 61 of file ZGPeerSession.h.

virtual status_t JuniorUpdateLocalDatabase ( uint32  whichDatabase,
uint32 &  dbChecksum,
const ConstMessageRef &  juniorDoMsg 
)
protectedvirtual

This method will only be called on junior peers.

It must be implemented to update the junior peer's local database according to the instructions contained in (juniorDoMsg).

Parameters
whichDatabaseThe index of the database to update (e.g. 0 for the first database, 1 for the second, and so on)
dbChecksumPassed in as the database's current checksum value. On return, this should be set to the database's new (post-update) checksum value.
juniorDoMsgReference to a Message instructing the junior peer how his lcoal database should be updated. (The contents and semantics of this Message will be determined by logic in the subclass of this class; they are not specified by the ZGPeerSession class itself)
Returns
on success, returns B_NO_ERROR. On failure (or refusal-to-update), returns B_ERROR.

Implements ZGPeerSession.

virtual void LocalSeniorPeerStatusChanged ( )
virtualinherited

Called whenever this peer has gained or lost senior-peer status (current status is indicated by the return value of IAmTheSeniorPeer())

virtual void MessageReceivedFromGateway ( const MessageRef &  msg,
void *  userData 
)
protectedvirtualinherited

Implemented as a no-op, since by default this session doesn't have a gateway.

virtual void NetworkInterfacesChanged ( const Hashtable< String, Void > &  optInterfaceNames)
inlinevirtualinherited

Called when the set of available network interfaces on this computer has changed.

Default implementation is a no-op.

Parameters
optInterfaceNamesAn optional list of network-interface names (e.g. "eth0", "eth1") that are known to have changed. If empty, then you should assume that any or all network interfaces have changed.

Definition at line 80 of file ZGPeerSession.h.

bool ParseGenericTextCommand ( const String &  cmd)
protectedinherited

Tries to handle any text commands that can be handled generically; that is, any commands that can be handled without knowing anything about this particular application.

This logic is broken out into a separate function so that it can be called by the stdin-text handlers of various daemons.

Parameters
cmdthe command text to parse
Returns
true if the command was handled, false if it wasn't.
virtual void PeerHasComeOnline ( const ZGPeerID peerID,
const ConstMessageRef &  peerInfo 
)
protectedvirtualinherited

Called when a new peer has joined our group.

Parameters
peerIDThe unique ID of the peer who is now online. (Note that this ID may be our own ID!)
peerInfoAn optional Message containing some additional information about that peer, if that peer specified any additional information in his ZGPeerSettings object. May be a NULL reference otherwise.

Reimplemented in ChoirSession.

virtual void PeerHasGoneOffline ( const ZGPeerID peerID,
const ConstMessageRef &  peerInfo 
)
protectedvirtualinherited

Called when a peer has left our group.

Parameters
peerIDThe unique ID of the peer who is now offline.
peerInfoAn optional Message containing some additional information about that peer, if that peer specified any additional information in his ZGPeerSettings object. May be a NULL reference otherwise.

Reimplemented in ChoirSession.

void PrintDatabaseStateInfo ( int32  whichDatabase = -1) const
protectedinherited

Prints various database-state information to stdout.

Useful for debugging purposes.

Parameters
whichDatabaseIndex of the database to print out state for, or leave set to -1 to print out info about all databases.
void PrintDatabaseUpdateLog ( int32  whichDatabase = -1) const
protectedinherited

Prints the database update-log(s) to stdout.

Useful for debugging purposes.

Parameters
whichDatabaseIndex of the database to print out the update-log for, or leave set to -1 to print out the update-logs of all databases.
virtual void Pulse ( const PulseArgs &  args)
virtualinherited

Called at (approximately) the time specified by GetPulseTime().

Parameters
argsContext information for this call (including the current time and the time at which this method was supposed to be called at)

Reimplemented in ChoirSession.

status_t RequestReplaceDatabaseState ( uint32  whichDatabase,
const MessageRef &  newDatabaseStateMsg 
)
protectedinherited

Call this if you want to request that the specified database be completely replaced with a new state that is specified by the passed-in Message.

The new database state will be created by calling SetLocalDatabaseFromMessage(newDatabaseStateMsg) on the senior peer. Note that this method only sends the request; the actual database-replace will happen (if it happens) some time after this method returns.

Parameters
whichDatabasethe index of the database whose state should be replaced.
newDatabaseStateMsga Message containing instructions/data that SetLocalDatabaseFromMessage() can use later on to create a new database state.
Returns
B_NO_ERROR if the the replace-request was successfully sent to the senior peer, or B_ERROR if the request could not be sent.
status_t RequestResetDatabaseStateToDefault ( uint32  whichDatabase)
protectedinherited

Call this if you want to request that the specified database be reset back to its well-known default state.

The well-known default state is defined by the implementation of the subclass's ResetLocalDatabaseToDefault() method. Note that this method only sends the request; the actual reset will happen (if it happens) some time after this method returns.

Parameters
whichDatabasethe index of the database that should be reset
Returns
B_NO_ERROR if the the reset-request was successfully sent to the senior peer, or B_ERROR if the request could not be sent.
status_t RequestUpdateDatabaseState ( uint32  whichDatabase,
const MessageRef &  databaseUpdateMsg 
)
protectedinherited

Call this if you want to request that the specified database be incrementally updated to a new state via a specified passed-in Message.

The new database state will be created by calling SeniorUpdateLocalDatabase(databaseUpdateMsg) on the senior peer, and then the Message returned by that method call will be used to update the local database of all of the other peers. Note that this method only sends the request; the actual database-update will happen (if it happens) some time after this method returns.

Parameters
whichDatabasethe index of the database whose state should be updated.
databaseUpdateMsga Message containing instructions/data that SeniorUpdateLocalDatabase() can use later on to transition the database to a new database state.
Returns
B_NO_ERROR if the the update-request was successfully sent to the senior peer, or B_ERROR if the request could not be sent.
virtual void ResetLocalDatabaseToDefault ( uint32  whichDatabase,
uint32 &  dbChecksum 
)
protectedvirtual

Must be implemented to reset local state of the specified database to its well-known default state.

Parameters
whichDatabaseThe index of the database to reset (e.g. 0 for the first database, 1 for the second, and so on)
dbChecksumPassed in as the database's current checksum value. On return, this should be set to the database's new checksum value.

Implements ZGPeerSession.

virtual MessageRef SaveLocalDatabaseToMessage ( uint32  whichDatabase) const
protectedvirtual

This method should be implemented to save the state of the specified local database into a Message.

Parameters
whichDatabaseThe index of the database to save (e.g. 0 for the first database, 1 for the second, and so on)
Returns
a MessageRef containing the full current state of the local database, or a NULL MessageRef on failure.

Implements ZGPeerSession.

status_t SendMulticastUserMessageToAllPeers ( const MessageRef &  msg)
protectedinherited

Tries to send the given Message to all peers (except this one) via UDP multicast.

The PacketTunnelIOGateway mechanism is used so that large Messages can be transmitted as well as small ones. Delivery is not guaranteed, however.

Parameters
msgThe Message object to send. MessageReceivedFromPeer() will be called on each peer when the Message arrives there.
Returns
B_NO_ERROR if the Message was successfully enqueued to be multicasted out, of B_ERROR otherwise.
status_t SendUnicastUserMessageToAllPeers ( const MessageRef &  msg)
protectedinherited

Tries to send the given Message to all peers (except this one) via multiple instances of TCP unicast.

Parameters
msgThe Message object to send. MessageReceivedFromPeer() will be called on each peer when the Message arrives there.
Returns
B_NO_ERROR if the Message was successfully enqueued to be multicasted out, of B_ERROR otherwise.
status_t SendUnicastUserMessageToPeer ( const ZGPeerID destinationPeerID,
const MessageRef &  msg 
)
protectedinherited

Tries to send the given Message to a specific peers via TCP unicast.

Parameters
destinationPeerIDThe ZGPeerID of the peer we want this Message to be sent to.
msgThe Message object to send. MessageReceivedFromPeer() will be called on the peer when the Message arrives there.
Returns
B_NO_ERROR if the Message was successfully enqueued to be unicasted out, of B_ERROR otherwise.
virtual void SeniorPeerChanged ( const ZGPeerID oldSeniorPeerID,
const ZGPeerID newSeniorPeerID 
)
protectedvirtualinherited

Called when the senior peer of our peer group has changed.

Parameters
oldSeniorPeerIDThe unique ID of the peer who was the senior peer but no longer is. (May be a zero/invalid if there wasn't any senior peer before)
newSeniorPeerIDThe unique ID of the peer who is now the senior peer. (May be a zero/invalid if there is no senior peer anymore)

Reimplemented in ChoirSession.

virtual ConstMessageRef SeniorUpdateLocalDatabase ( uint32  whichDatabase,
uint32 &  dbChecksum,
const ConstMessageRef &  seniorDoMsg 
)
protectedvirtual

This method will only be called on the senior peer.

It must be implemented to update the senior peer's local database and return a MessageRef that the system can later use to update same database on the various junior peers in the same way later on.

Parameters
whichDatabaseThe index of the database to update (e.g. 0 for the first database, 1 for the second, and so on)
dbChecksumPassed in as the database's current checksum value. On return, this should be set to the database's new (post-update) checksum value.
seniorDoMsgReference to a Message instructing the senior peer how his local database should be updated. (The contents and semantics of this Message will be determined by logic in the subclass of this class; they are not specified by the ZGPeerSession class itself)
Returns
on success, this method should return a MessageRef that can be sent on to the junior peers to tell them how to update their local database so that their local database ends up in the same post-change state that our local database is currently in. Returning (seniorDoMsg) is acceptable if that is a Message that will cause the junior peers to do the right thing. On failure (or refusal-to-handle-the-update), a NULL MessageRef() should be returned.

Implements ZGPeerSession.

virtual status_t SetLocalDatabaseFromMessage ( uint32  whichDatabase,
uint32 &  dbChecksum,
const ConstMessageRef &  newDBStateMsg 
)
protectedvirtual

This method should be implemented to replace the current state of the specified local database with the new state represented by the passed-in Message.

Parameters
whichDatabaseThe index of the database to replace (e.g. 0 for the first database, 1 for the second, and so on)
dbChecksumPassed in as the database's current checksum value. On return, this should be set to the database's new (post-update) checksum value.
newDBStateMsgA Message holding the contents of the new database we want to replace the current database with.
Returns
B_NO_ERROR on success, or B_ERROR on failure.

Implements ZGPeerSession.

virtual bool TextCommandReceived ( const String &  text)
virtualinherited

Default implementation handles some standard ZG commands such as "print peers" or "print sessions".

Parameters
textA text string was received via our stdin stream.
Returns
true if the command was recognized and handled, or false otherwise.

Implements ITextCommandReceiver.


The documentation for this class was generated from the following file: