DumbReflectSession Class Reference

This class represents a single TCP connection between a muscled server and a client program. More...

#include <DumbReflectSession.h>

Inheritance diagram for DumbReflectSession:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 DumbReflectSession ()
 Default constructor.
virtual ~DumbReflectSession ()
 Destructor.
virtual void MessageReceivedFromGateway (const MessageRef &msg, void *userData)
 Called whenever a new incoming Message is available for us to look at.
virtual void MessageReceivedFromSession (AbstractReflectSession &from, const MessageRef &msg, void *userData)
 Called when a message is sent to us by another session (possibly this one).
void SetReflectToSelf (bool reflectToSelf)
 Set this true to enable self-reflection: if true, messages sent by a given client will be reflected back to that client.
bool GetReflectToSelf () const
 Returns true iff our client's own messages will be bounced back to him.
virtual const char * GetTypeName () const
 Returns a human-readable label for our session type: "Dumb Session".
const StringGetHostName () const
 Returns the hostname of this client that is associated with this session.
uint16 GetPort () const
 Returns the server-side port that this session was accepted on, or 0 if we weren't accepted from a port (e.g.
const ip_address & GetLocalInterfaceAddress () const
 Returns the server-side network interface IP that this session was accepted on, or 0 if we weren't created via accepting a network connection (e.g.
uint32 GetSessionID () const
 Returns a globally unique ID for this session.
const StringGetSessionIDString () const
 Returns an ID string to represent this session with.
void EndSession ()
 Marks this session for immediate termination and removal from the server.
bool DisconnectSession ()
 Forces the disconnection of this session's TCP connection to its client.
status_t ReplaceSession (const AbstractReflectSessionRef &newSession)
 Causes this session to be terminated (similar to EndSession(), and the session specified in (newSessionRef) to take its place using the same socket connection & message IO gateway.
virtual bool ClientConnectionClosed ()
 Called when the TCP connection to our client is broken.
virtual void AsyncConnectCompleted ()
 For sessions that were added to the server with AddNewConnectSession(), or AddNewDormantConnectSession(), this method is called when the asynchronous connect process completes successfully.
void SetInputPolicy (const PolicyRef &newPolicy)
 Set a new input I/O policy for this session.
PolicyRef GetInputPolicy () const
 Returns a reference to the current input policy for this session.
void SetOutputPolicy (const PolicyRef &newPolicy)
 Set a new output I/O policy for this session.
PolicyRef GetOutputPolicy () const
 Returns a reference to the current output policy for this session.
void SetGateway (const AbstractMessageIOGatewayRef &ref)
 Installs the given AbstractMessageIOGateway as the gateway we should use for I/O.
const AbstractMessageIOGatewayRefGetGateway () const
 Returns a reference to our internally held message IO gateway object, or NULL reference if there is none.
virtual bool HasBytesToOutput () const
 Should return true iff we have data pending for output.
virtual bool IsReadyForInput () const
 Should return true iff we are willing to read more bytes from our client connection at this time.
virtual int32 DoInput (AbstractGatewayMessageReceiver &receiver, uint32 maxBytes)
 Called by the ReflectServer when it wants us to read some more bytes from our client.
virtual int32 DoOutput (uint32 maxBytes)
 Called by the ReflectServer when it wants us to push some more bytes out to our client.
virtual SocketRef CreateDefaultSocket ()
 Socket factory method.
virtual DataIORef CreateDataIO (const SocketRef &socket)
 DataIO factory method.
virtual AbstractMessageIOGatewayRef CreateGateway ()
 Gateway factory method.
virtual uint64 GetPulseTime (uint64 now, uint64 sched)
 Overridden to support auto-reconnect via SetAutoReconnectDelay().
virtual void Pulse (uint64 now, uint64 sched)
 Overridden to support auto-reconnect via SetAutoReconnectDelay().
virtual String GetDefaultHostName () const
 May be overridden to return the host name string we should be assigned if no host name could be automatically determined by the ReflectServer (i.e.
String GetSessionDescriptionString () const
 Convenience method -- returns a human-readable string describing our type, our hostname, our session ID, and what port we are connected to.
const ip_address & GetAsyncConnectIP () const
 Returns the IP address we connected asynchronously to.
uint16 GetAsyncConnectPort () const
 Returns the remote port we connected asynchronously to.
virtual const StringGetSessionRootPath () const
 Returns the node path of the node representing this session (e.g.
void SetAutoReconnectDelay (uint64 delay)
 Sets the amount of time that should pass between when this session loses its connection (that was previously set up using AddNewConnectSession() or AddNewDormantConnectSession()) and when it should automatically try to reconnect to that same destination (by calling Reconnect()).
uint64 GetAutoReconnectDelay () const
 Returns the current automatic-reconnect delay period, as was previously set by SetAutoReconnectDelay().
bool IsConnectingAsync () const
 Returns true iff we are currently in the middle of an asynchronous TCP connection.
bool IsConnected () const
 Returns true iff this session is currently connected to our remote counterpart.
virtual status_t AttachedToServer ()
 This method is called when this object has been added to a ReflectServer object.
virtual void AboutToDetachFromServer ()
 This method is called just before we are removed from the ReflectServer object.
virtual void MessageReceivedFromFactory (ReflectSessionFactory &from, const MessageRef &msg, void *userData)
 Called when a message is sent to us by a ReflectSessionFactory object.
bool IsAttachedToServer () const
 Returns true if we are attached to the ReflectServer object, false if we are not.
ReflectServerGetOwner () const
 Returns the ReflectServer we are currently attached to, or NULL if we aren't currently attached to a ReflectServer.
void SetOwner (ReflectServer *s)
 Sets the ReflectServer we are currently attached to.
void IncrementRefCount () const
 Increments the counter and returns true iff the new value is zero.
bool DecrementRefCount () const
 Decrements the counter and returns true iff the new value is zero.
void SetManager (AbstractObjectManager *manager)
 Sets the recycle-pointer for this object.
AbstractObjectManagerGetManager () const
 Returns this object's current recyler pointer.
uint32 GetRefCount () const
 Returns this object's current reference count.
status_t PutPulseChild (PulseNode *child)
 Adds the given child into our set of child PulseNodes.
status_t RemovePulseChild (PulseNode *child)
 Attempts to remove the given child from our set of child PulseNodes.
void ClearPulseChildren ()
 Removes all children from our set of child PulseNodes.
bool ContainsPulseChild (PulseNode *child) const
 Returns true iff the given child is in our set of child PulseNodes.
uint64 GetScheduledPulseTime () const
 Returns when this object wants its call to Pulse() scheduled next, or MUSCLE_TIME_NEVER if it has no call to Pulse() currently scheduled.
uint64 GetCycleStartTime () const
 Returns the run-time at which the PulseNodeManager started calling our callbacks.
void SetSuggestedMaximumTimeSlice (uint64 maxUsecs)
 Sets the maximum number of microseconds that this class should allow its callback methods to execute for (relative to the cycle start time, as shown above).
uint64 GetSuggestedMaximumTimeSlice () const
 Returns the current suggested maximum duration of our time slice, or MUSCLE_TIME_NEVER if there is no suggested limit.
bool IsSuggestedTimeSliceExpired () const
 Convenience method -- returns true iff the current value of the run-time clock (GetRunTime64()) indicates that our suggested time slice has expired.
void CallMessageReceivedFromGateway (const MessageRef &msg, void *userData=NULL)
 This method calls MessageReceivedFromGateway() and then AfterMessageReceivedFromGateway().

Protected Member Functions

virtual status_t AddOutgoingMessage (const MessageRef &ref)
 Adds a MessageRef to our gateway's outgoing message queue.
void BroadcastToAllSessions (const MessageRef &msgRef, void *userData=NULL, bool includeSelf=true)
 Convenience method: Calls MessageReceivedFromSession() on all session objects.
void BroadcastToAllFactories (const MessageRef &msgRef, void *userData=NULL)
 Convenience method: Calls MessageReceivedFromSession() on all installed session-factory objects.
status_t Reconnect ()
 Closes this session's current TCP connection (if any), and creates a new TCP socket that will then try to asynchronously connect back to the previous socket's host and port.
const SocketRefGetSessionSelectSocket () const
 Convenience method: Returns the file descriptor associated with this session's DataIO class, or a NULL reference if there is none.
void SetSessionRootPath (const String &p)
 Set by StorageReflectSession::AttachedToServer().
uint64 GetServerUptime () const
 Returns the number of milliseconds that the server has been running.
uint32 GetNumAvailableBytes () const
 Returns the number of bytes that are currently available to be allocated.
uint32 GetMaxNumBytes () const
 Returns the maximum number of bytes that may be allocated at any given time.
uint32 GetNumUsedBytes () const
 Returns the number of bytes that are currently allocated.
status_t PutAcceptFactory (uint16 port, const ReflectSessionFactoryRef &factoryRef, const ip_address &interfaceIP=invalidIP, uint16 *optRetPort=NULL)
 Passes through to ReflectServer::PutAcceptFactory().
status_t RemoveAcceptFactory (uint16 port, const ip_address &interfaceIP=invalidIP)
 Passes through to ReflectServer::RemoveAcceptFactory().
void EndServer ()
 Tells the whole server process to quit ASAP.
MessageGetCentralState () const
 Returns a reference to a Message that is shared by all objects in a single ReflectServer.
status_t AddNewSession (const AbstractReflectSessionRef &session, const SocketRef &socket=SocketRef())
 Adds the given AbstractReflectSession to the server's session list.
status_t AddNewConnectSession (const AbstractReflectSessionRef &session, const ip_address &targetIPAddress, uint16 port, uint64 autoReconnectDelay=MUSCLE_TIME_NEVER)
 Like AddNewSession(), only creates a session that connects asynchronously to the given IP address.
status_t AddNewDormantConnectSession (const AbstractReflectSessionRef &ref, const ip_address &targetIPAddress, uint16 port, uint64 autoReconnectDelay=MUSCLE_TIME_NEVER)
 Like AddNewConnectSession(), except that the added session will not initiate a TCP connection to the specified address immediately.
const Hashtable< const String *,
AbstractReflectSessionRef > & 
GetSessions () const
 Returns our server's table of attached sessions.
AbstractReflectSessionRef GetSession (uint32 id) const
 Looks up a session connected to our ReflectServer via its session ID string.
AbstractReflectSessionRef GetSession (const String &id) const
 Looks up a session connected to our ReflectServer via its session ID string.
const Hashtable< IPAddressAndPort,
ReflectSessionFactoryRef > & 
GetFactories () const
 Returns the table of session factories currently attached to the server.
ReflectSessionFactoryRef GetFactory (uint16) const
 Given a port number, returns a reference to the factory of that port, or a NULL reference if no such factory exists.
void InvalidatePulseTime (bool clearPrevResult=true)
 Sets a flag to indicate that GetPulseTime() should be called on this object.
virtual void AfterMessageReceivedFromGateway (const MessageRef &msg, void *userData)
 Called after each call to MessageReceivedFromGateway().
virtual void BeginMessageReceivedFromGatewayBatch ()
 This method will be called just before MessageReceivedFromGateway() and AfterMessageReceivedFromGateway() are called one or more times.
virtual void EndMessageReceivedFromGatewayBatch ()
 This method will be called just after MessageReceivedFromGateway() and AfterMessageReceivedFromGateway() have been called one or more times.

Detailed Description

This class represents a single TCP connection between a muscled server and a client program.

This class implements a simple "reflect-all-messages-to-all-clients" message forwarding strategy, but may be subclassed to perform more complex message routing logic.

Definition at line 24 of file DumbReflectSession.h.


Member Function Documentation

virtual void DumbReflectSession::MessageReceivedFromGateway ( const MessageRef msg,
void *  userData 
) [virtual]

Called whenever a new incoming Message is available for us to look at.

Parameters:
msg Reference to the new Message to process.
userData This is a miscellaneous value that may be used by some gateways for various purposes.

Implements AbstractGatewayMessageReceiver.

Reimplemented in StorageReflectSession, ThreadWorkerSession, and ThreadSupervisorSession.

virtual void DumbReflectSession::MessageReceivedFromSession ( AbstractReflectSession from,
const MessageRef msg,
void *  userData 
) [virtual]

Called when a message is sent to us by another session (possibly this one).

Parameters:
from The session that is sending us the message.
msg Reference to the message that we are receiving.
userData This is a user value whose semantics are defined by the subclass.

Reimplemented from ServerComponent.

Reimplemented in ThreadWorkerSession, and ThreadSupervisorSession.

void DumbReflectSession::SetReflectToSelf ( bool  reflectToSelf  ) 

Set this true to enable self-reflection: if true, messages sent by a given client will be reflected back to that client.

Default state is false (i.e. messages only go to everyone else)

Parameters:
reflectToSelf Whether or not our client's own messages should be bounced back to him.

const String& AbstractReflectSession::GetHostName (  )  const [inherited]

Returns the hostname of this client that is associated with this session.

May only be called if this session is currently attached to a ReflectServer.

uint16 AbstractReflectSession::GetPort (  )  const [inherited]

Returns the server-side port that this session was accepted on, or 0 if we weren't accepted from a port (e.g.

we were created locally) May only be called if this session is currently attached to a ReflectServer.

const ip_address& AbstractReflectSession::GetLocalInterfaceAddress (  )  const [inherited]

Returns the server-side network interface IP that this session was accepted on, or 0 if we weren't created via accepting a network connection (e.g.

we were created locally) May only be called if this session is currently attached to a ReflectServer.

const String& AbstractReflectSession::GetSessionIDString (  )  const [inline, inherited]

Returns an ID string to represent this session with.

(This string is the ASCII representation of GetSessionID())

Definition at line 132 of file AbstractReflectSession.h.

bool AbstractReflectSession::DisconnectSession (  )  [inherited]

Forces the disconnection of this session's TCP connection to its client.

Calling this will cause ClientConnectionClosed() to be called, as if the TCP connection had been severed externally.

Returns:
the value that ClientConnectionClosed() returned.

status_t AbstractReflectSession::ReplaceSession ( const AbstractReflectSessionRef newSession  )  [inherited]

Causes this session to be terminated (similar to EndSession(), and the session specified in (newSessionRef) to take its place using the same socket connection & message IO gateway.

Parameters:
newSession the new session object that is to take the place of this one.
Returns:
B_NO_ERROR on success, B_ERROR if the new session refused to be attached.

virtual bool AbstractReflectSession::ClientConnectionClosed (  )  [virtual, inherited]

Called when the TCP connection to our client is broken.

If this method returns true, then this session will be removed and deleted.

Returns:
If it returns false, then this session will continue, even though the client is no longer available. Default implementation always returns true, unless the automatic-reconnect feature has been enabled (via SetAutoReconnectDelay()), in which case this method will return false and try to Reconnect() again, instead.

Reimplemented in ThreadWorkerSession, and ThreadSupervisorSession.

virtual void AbstractReflectSession::AsyncConnectCompleted (  )  [virtual, inherited]

For sessions that were added to the server with AddNewConnectSession(), or AddNewDormantConnectSession(), this method is called when the asynchronous connect process completes successfully.

(if the asynchronous connect fails, ClientConnectionClosed() is called instead). Default implementation just sets an internal flag that governs whether an error message should be printed when the session is disconnected later on.

Reimplemented in ThreadWorkerSession.

void AbstractReflectSession::SetInputPolicy ( const PolicyRef newPolicy  )  [inherited]

Set a new input I/O policy for this session.

Parameters:
newPolicy Reference to the new policy to use to control the incoming byte stream for this session. May be a NULL reference if you just want to remove the existing policy.

PolicyRef AbstractReflectSession::GetInputPolicy (  )  const [inline, inherited]

Returns a reference to the current input policy for this session.

May be a NULL reference, if there is no input policy installed (which is the default state)

Definition at line 185 of file AbstractReflectSession.h.

void AbstractReflectSession::SetOutputPolicy ( const PolicyRef newPolicy  )  [inherited]

Set a new output I/O policy for this session.

Parameters:
newPolicy Reference to the new policy to use to control the outgoing byte stream for this session. May be a NULL reference if you just want to remove the existing policy.

PolicyRef AbstractReflectSession::GetOutputPolicy (  )  const [inline, inherited]

Returns a reference to the current output policy for this session.

May be a NULL reference. May be a NULL reference, if there is no output policy installed (which is the default state)

Definition at line 197 of file AbstractReflectSession.h.

void AbstractReflectSession::SetGateway ( const AbstractMessageIOGatewayRef ref  )  [inline, inherited]

Installs the given AbstractMessageIOGateway as the gateway we should use for I/O.

If this method isn't called, the ReflectServer will call our CreateGateway() method to set our gateway for us when we are attached.

Parameters:
ref Reference to the I/O gateway to use, or a NULL reference to remove any gateway we have.

Definition at line 204 of file AbstractReflectSession.h.

const AbstractMessageIOGatewayRef& AbstractReflectSession::GetGateway (  )  const [inline, inherited]

Returns a reference to our internally held message IO gateway object, or NULL reference if there is none.

The returned gateway remains the property of this session.

Definition at line 211 of file AbstractReflectSession.h.

virtual bool AbstractReflectSession::HasBytesToOutput (  )  const [virtual, inherited]

Should return true iff we have data pending for output.

Default implementation calls HasBytesToOutput() on our installed AbstractDataIOGateway object, if we have one, or returns false if we don't.

virtual bool AbstractReflectSession::IsReadyForInput (  )  const [virtual, inherited]

Should return true iff we are willing to read more bytes from our client connection at this time.

Default implementation calls IsReadyForInput() on our install AbstractDataIOGateway object, if we have one, or returns false if we don't.

virtual int32 AbstractReflectSession::DoInput ( AbstractGatewayMessageReceiver receiver,
uint32  maxBytes 
) [virtual, inherited]

Called by the ReflectServer when it wants us to read some more bytes from our client.

Default implementation simply calls DoInput() on our Gateway object (if any).

Parameters:
receiver Object to call CallMessageReceivedFromGateway() on when new Messages are ready to be looked at.
maxBytes Maximum number of bytes to read before returning.
Returns:
The total number of bytes read, or -1 if there was a fatal error.

virtual int32 AbstractReflectSession::DoOutput ( uint32  maxBytes  )  [virtual, inherited]

Called by the ReflectServer when it wants us to push some more bytes out to our client.

Default implementation simply calls DoOutput() on our Gateway object (if any).

Parameters:
maxBytes Maximum number of bytes to write before returning.
Returns:
The total number of bytes written, or -1 if there was a fatal error.

Reimplemented in ThreadWorkerSession.

virtual SocketRef AbstractReflectSession::CreateDefaultSocket (  )  [virtual, inherited]

Socket factory method.

This method is called by AddNewSession() when no valid Socket was supplied as an argument to the AddNewSession() call. This method should either create and supply a default Socket, or return a NULL SocketRef. In the latter case, the session will run without any connection to a client. Default implementation always returns a NULL SocketRef.

virtual DataIORef AbstractReflectSession::CreateDataIO ( const SocketRef socket  )  [virtual, inherited]

DataIO factory method.

Should return a new non-blocking DataIO object for our gateway to use, or NULL on failure. Called by ReflectServer when this session is added to the server. The default implementation returns a non-blocking TCPSocketDataIO object, which is the correct behaviour 99% of the time.

Parameters:
socket The socket to provide the DataIO object for. On success, the DataIO object becomes owner of (socket).
Returns:
A newly allocated DataIO object, or NULL on failure.

virtual AbstractMessageIOGatewayRef AbstractReflectSession::CreateGateway (  )  [virtual, inherited]

Gateway factory method.

Should return a reference to a new AbstractMessageIOGateway for this session to use for communicating with its remote peer. Called by ReflectServer when this session object is added to the server, but doesn't already have a valid gateway installed. The default implementation returns a MessageIOGateway object.

Returns:
a new message IO gateway object, or a NULL reference on failure.

Reimplemented in ThreadSupervisorSession.

virtual String AbstractReflectSession::GetDefaultHostName (  )  const [virtual, inherited]

May be overridden to return the host name string we should be assigned if no host name could be automatically determined by the ReflectServer (i.e.

if we had no associated socket at the time). Default implementation returns "<unknown>".

const ip_address& AbstractReflectSession::GetAsyncConnectIP (  )  const [inline, inherited]

Returns the IP address we connected asynchronously to.

The returned value is meaningful only if we were added with AddNewConnectSession() or AddNewDormantConnectSession().

Definition at line 299 of file AbstractReflectSession.h.

References IPAddressAndPort::GetIPAddress().

uint16 AbstractReflectSession::GetAsyncConnectPort (  )  const [inline, inherited]

Returns the remote port we connected asynchronously to.

The returned value is meaningful only if we were added with AddNewConnectSession() or AddNewDormantConnectSession().

Definition at line 305 of file AbstractReflectSession.h.

References IPAddressAndPort::GetPort().

virtual const String& AbstractReflectSession::GetSessionRootPath (  )  const [inline, virtual, inherited]

Returns the node path of the node representing this session (e.g.

"/192.168.1.105/17")

Definition at line 308 of file AbstractReflectSession.h.

void AbstractReflectSession::SetAutoReconnectDelay ( uint64  delay  )  [inline, inherited]

Sets the amount of time that should pass between when this session loses its connection (that was previously set up using AddNewConnectSession() or AddNewDormantConnectSession()) and when it should automatically try to reconnect to that same destination (by calling Reconnect()).

Default setting is MUSCLE_TIME_NEVER, meaning that automatic reconnection is disabled.

Parameters:
delay The amount of time to delay before reconnecting, in microseconds.

Definition at line 316 of file AbstractReflectSession.h.

References PulseNode::InvalidatePulseTime().

uint64 AbstractReflectSession::GetAutoReconnectDelay (  )  const [inline, inherited]

Returns the current automatic-reconnect delay period, as was previously set by SetAutoReconnectDelay().

Note that this setting is only relevant for sessions that were attached using AddNewConnectSession() or AddNewDormantConnectSession().

Definition at line 322 of file AbstractReflectSession.h.

virtual status_t AbstractReflectSession::AddOutgoingMessage ( const MessageRef ref  )  [protected, virtual, inherited]

Adds a MessageRef to our gateway's outgoing message queue.

(ref) will be sent back to our client when time permits.

Parameters:
ref Reference to a Message to send to our client.
Returns:
B_NO_ERROR on success, B_ERROR if out-of-memory.

void AbstractReflectSession::BroadcastToAllSessions ( const MessageRef msgRef,
void *  userData = NULL,
bool  includeSelf = true 
) [protected, inherited]

Convenience method: Calls MessageReceivedFromSession() on all session objects.

Saves you from having to do your own iteration every time you want to broadcast something.

Parameters:
msgRef a reference to the Message you wish to broadcast
userData any userData value you care to include. Defaults to NULL.
includeSelf Whether or not MessageReceivedFromSession() should be called on 'this' session. Defaults to true.
See also:
GetSessions(), AddNewSession(), GetSession()

void AbstractReflectSession::BroadcastToAllFactories ( const MessageRef msgRef,
void *  userData = NULL 
) [protected, inherited]

Convenience method: Calls MessageReceivedFromSession() on all installed session-factory objects.

Saves you from having to do your own iteration every time you want to broadcast something to the factories.

Parameters:
msgRef a reference to the Message you wish to broadcast
userData any userData value you care to include. Defaults to NULL.
See also:
GetFactories(), PutFactory(), GetFactory()

status_t AbstractReflectSession::Reconnect (  )  [protected, inherited]

Closes this session's current TCP connection (if any), and creates a new TCP socket that will then try to asynchronously connect back to the previous socket's host and port.

Note that this method is primarily useful for sessions that were added with AddNewConnectSession() or AddNewDormantConnectSession(); for other types of session, it will just destroy this session's DataIO and IOGateway and then create new ones by calling CreateDefaultSocket() and CreateDataIO().

Note:
This method will call CreateDataIO() to make a new DataIO object for the newly created socket.
Returns:
B_NO_ERROR on success, or B_ERROR on failure. On success, the connection result will be reported back later, either via a call to AsyncConnectCompleted() (if the connection succeeds) or a call to ClientConnectionClosed() (if the connection fails)

virtual status_t ServerComponent::AttachedToServer (  )  [virtual, inherited]

This method is called when this object has been added to a ReflectServer object.

When this method is called, it is okay to call the other methods in the ServerComponent API. Should return B_NO_ERROR if everything is okay; something else if there is a problem and the attachment should be aborted. Default implementation does nothing and returns B_NO_ERROR. If you override this, be sure to call your superclass's implementation of this method as the first thing in your implementation, and if it doesn't return B_NO_ERROR, immediately return an error yourself.

Reimplemented in ProxySessionFactory, StorageReflectSession, ThreadWorkerSession, and ThreadWorkerSessionFactory.

virtual void ServerComponent::AboutToDetachFromServer (  )  [virtual, inherited]

This method is called just before we are removed from the ReflectServer object.

Methods in the ServerComponent API may still be called at this time (but not after this method returns). Default implementation does nothing. If you override this, be sure to call you superclass's implementation of this method as the last thing you do in your implementation.

Reimplemented in ProxySessionFactory, StorageReflectSession, ThreadWorkerSession, ThreadWorkerSessionFactory, and ThreadSupervisorSession.

virtual void ServerComponent::MessageReceivedFromFactory ( ReflectSessionFactory from,
const MessageRef msg,
void *  userData 
) [virtual, inherited]

Called when a message is sent to us by a ReflectSessionFactory object.

Default implementation is a no-op.

Parameters:
from The session who is sending the Message to us.
msg A reference to the message that was sent.
userData Additional data whose semantics are determined by the sending subclass.

Reimplemented in ThreadSupervisorSession.

void ServerComponent::SetOwner ( ReflectServer s  )  [inline, inherited]

Sets the ReflectServer we are currently attached to.

Don't call this if you don't know what you are doing.

Definition at line 87 of file ServerComponent.h.

Message& ServerComponent::GetCentralState (  )  const [protected, inherited]

Returns a reference to a Message that is shared by all objects in a single ReflectServer.

This message can be used for whatever purpose the ServerComponents care to; it is not used by the server itself. (Note that StorageReflectSessions add data to this Message and expect it to remain there, so be careful not to remove or overwrite it if you are using StorageReflectSessions)

status_t ServerComponent::AddNewSession ( const AbstractReflectSessionRef session,
const SocketRef socket = SocketRef() 
) [protected, inherited]

Adds the given AbstractReflectSession to the server's session list.

If (socket) is less than zero, no TCP connection will be used, and the session will be a pure server-side entity.

Parameters:
session A reference to the new session to add to the server.
socket the socket descriptor associated with the new session, or a NULL reference. If the socket descriptor argument is a NULL reference, the session's CreateDefaultSocket() method will be called to supply the SocketRef. If that also returns a NULL reference, then the client will run without a connection to anything.
Returns:
B_NO_ERROR if the session was successfully added, or B_ERROR on error.

status_t ServerComponent::AddNewConnectSession ( const AbstractReflectSessionRef session,
const ip_address &  targetIPAddress,
uint16  port,
uint64  autoReconnectDelay = MUSCLE_TIME_NEVER 
) [protected, inherited]

Like AddNewSession(), only creates a session that connects asynchronously to the given IP address.

AttachedToServer() will be called immediately on the session, and then when the connection is complete, AsyncConnectCompleted() will be called. Other than that, however, (session) will behave like any other session, except any I/O messages for the client won't be transferred until the connection completes.

Parameters:
session A reference to the new session to add to the server.
targetIPAddress IP address to connect to
port port to connect to at that address
autoReconnectDelay If specified, this is the number of microseconds after the connection is broken that an automatic reconnect should be attempted. If not specified, an automatic reconnect will not be attempted, and the session will be removed when the connection breaks. Specifying this is equivalent to calling SetAutoReconnectDelay() on (session).
Returns:
B_NO_ERROR if the session was successfully added, or B_ERROR on error (out-of-memory or the connect attempt failed immediately).

status_t ServerComponent::AddNewDormantConnectSession ( const AbstractReflectSessionRef ref,
const ip_address &  targetIPAddress,
uint16  port,
uint64  autoReconnectDelay = MUSCLE_TIME_NEVER 
) [protected, inherited]

Like AddNewConnectSession(), except that the added session will not initiate a TCP connection to the specified address immediately.

Instead, it will just hang out and do nothing until you call Reconnect() on it. Only then will it create the TCP connection to the address specified here.

Parameters:
ref New session to add to the server.
targetIPAddress IP address to connect to
port Port to connect to at that IP address.
autoReconnectDelay If specified, this is the number of microseconds after the connection is broken that an automatic reconnect should be attempted. If not specified, an automatic reconnect will not be attempted, and the session will be removed when the connection breaks. Specifying this is equivalent to calling SetAutoReconnectDelay() on (ref).
Returns:
B_NO_ERROR if the session was successfully added, or B_ERROR on error (out-of-memory, or the connect attempt failed immediately)

AbstractReflectSessionRef ServerComponent::GetSession ( uint32  id  )  const [protected, inherited]

Looks up a session connected to our ReflectServer via its session ID string.

Parameters:
id The ID of the session you are looking for.
Returns:
A reference to the session with the given session ID, or a NULL reference on failure.

AbstractReflectSessionRef ServerComponent::GetSession ( const String id  )  const [protected, inherited]

Looks up a session connected to our ReflectServer via its session ID string.

Parameters:
id The ID string of the session you are looking for.
Returns:
A reference to the session with the given session ID, or a NULL reference on failure.

void RefCountable::IncrementRefCount (  )  const [inline, inherited]

Increments the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 32 of file RefCount.h.

References AtomicCounter::AtomicIncrement().

bool RefCountable::DecrementRefCount (  )  const [inline, inherited]

Decrements the counter and returns true iff the new value is zero.

Thread safe.

Definition at line 35 of file RefCount.h.

References AtomicCounter::AtomicDecrement().

void RefCountable::SetManager ( AbstractObjectManager manager  )  [inline, inherited]

Sets the recycle-pointer for this object.

If set to non-NULL, this pointer is used by the ObjectPool class to recycle this object when it is no longer in use, so as to avoid the overhead of having to delete it and re-create it later on. The RefCountable class itself does nothing with this pointer. Default value is NULL.

Parameters:
manager Pointer to the new manager object to use, or NULL to use no manager.

Definition at line 44 of file RefCount.h.

uint32 RefCountable::GetRefCount (  )  const [inline, inherited]

Returns this object's current reference count.

Note that the value returned by this method is volatile in multithreaded environments, so it may already be wrong by the time it is returned. Be careful!

Definition at line 54 of file RefCount.h.

References AtomicCounter::GetCount().

status_t PulseNode::PutPulseChild ( PulseNode child  )  [inherited]

Adds the given child into our set of child PulseNodes.

Any PulseNode in our set of children will have its pulsing needs taken care of by us, but it is not considered "owned" by this PulseNode--it will not be deleted when we are.

Parameters:
child The child to place into our set of child PulseNodes.
Returns:
B_NO_ERROR on success, or B_ERROR on failure (out of memory).

status_t PulseNode::RemovePulseChild ( PulseNode child  )  [inherited]

Attempts to remove the given child from our set of child PulseNodes.

Parameters:
child The child to remove
Returns:
B_NO_ERROR on success, or B_ERROR on failure (child wasn't in our set)

bool PulseNode::ContainsPulseChild ( PulseNode child  )  const [inline, inherited]

Returns true iff the given child is in our set of child PulseNodes.

Parameters:
child the child to look for.

Definition at line 84 of file PulseNode.h.

References PulseNode::_parent.

uint64 PulseNode::GetCycleStartTim