#include <AbstractReflectSession.h>
Inheritance diagram for AbstractReflectSession:

Public Member Functions | |
| AbstractReflectSession () | |
| Default Constructor. | |
| virtual | ~AbstractReflectSession () |
| Destructor. | |
| const String & | GetHostName () 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 String & | GetSessionIDString () 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 AbstractMessageIOGatewayRef & | GetGateway () 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 const char * | GetTypeName () const=0 |
| Should return a pretty, human readable string identifying this class. | |
| 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 String & | GetSessionRootPath () 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 | MessageReceivedFromSession (AbstractReflectSession &from, const MessageRef &msg, void *userData) |
| Called when a message is sent to us by an AbstractReflectSession 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. | |
| ReflectServer * | GetOwner () 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. | |
| AbstractObjectManager * | GetManager () 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 SocketRef & | GetSessionSelectSocket () 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. | |
| Message & | GetCentralState () 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 | MessageReceivedFromGateway (const MessageRef &msg, void *userData)=0 |
| Called whenever a new incoming Message is available for us to look at. | |
| 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. | |
Friends | |
| class | ReflectServer |
This class contains no message routing logic of its own, but defines the interface so that subclasses can do so.
Definition at line 99 of file AbstractReflectSession.h.
| const String& AbstractReflectSession::GetHostName | ( | ) | const |
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 |
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 |
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] |
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 | ( | ) |
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.
| status_t AbstractReflectSession::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.
| newSession | the new session object that is to take the place of this one. |
| virtual bool AbstractReflectSession::ClientConnectionClosed | ( | ) | [virtual] |
Called when the TCP connection to our client is broken.
If this method returns true, then this session will be removed and deleted.
Reimplemented in ThreadWorkerSession, and ThreadSupervisorSession.
| virtual void AbstractReflectSession::AsyncConnectCompleted | ( | ) | [virtual] |
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 | ) |
Set a new input I/O policy for this session.
| 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] |
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 | ) |
Set a new output I/O policy for this session.
| 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] |
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] |
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.
| 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] |
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] |
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] |
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] |
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).
| receiver | Object to call CallMessageReceivedFromGateway() on when new Messages are ready to be looked at. | |
| maxBytes | Maximum number of bytes to read before returning. |
| virtual int32 AbstractReflectSession::DoOutput | ( | uint32 | maxBytes | ) | [virtual] |
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).
| maxBytes | Maximum number of bytes to write before returning. |
Reimplemented in ThreadWorkerSession.
| virtual SocketRef AbstractReflectSession::CreateDefaultSocket | ( | ) | [virtual] |
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.
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.
| socket | The socket to provide the DataIO object for. On success, the DataIO object becomes owner of (socket). |
| virtual AbstractMessageIOGatewayRef AbstractReflectSession::CreateGateway | ( | ) | [virtual] |
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.
Reimplemented in ThreadSupervisorSession.
| virtual String AbstractReflectSession::GetDefaultHostName | ( | ) | const [virtual] |
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] |
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] |
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] |
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] |
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.
| 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] |
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] |
Adds a MessageRef to our gateway's outgoing message queue.
(ref) will be sent back to our client when time permits.
| ref | Reference to a Message to send to our client. |
| void AbstractReflectSession::BroadcastToAllSessions | ( | const MessageRef & | msgRef, | |
| void * | userData = NULL, |
|||
| bool | includeSelf = true | |||
| ) | [protected] |
Convenience method: Calls MessageReceivedFromSession() on all session objects.
Saves you from having to do your own iteration every time you want to broadcast something.
| 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. |
| void AbstractReflectSession::BroadcastToAllFactories | ( | const MessageRef & | msgRef, | |
| void * | userData = NULL | |||
| ) | [protected] |
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.
| msgRef | a reference to the Message you wish to broadcast | |
| userData | any userData value you care to include. Defaults to NULL. |
| status_t AbstractReflectSession::Reconnect | ( | ) | [protected] |
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().
| 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::MessageReceivedFromSession | ( | AbstractReflectSession & | from, | |
| const MessageRef & | msg, | |||
| void * | userData | |||
| ) | [virtual, inherited] |
Called when a message is sent to us by an AbstractReflectSession object.
Default implementation is a no-op.
| 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. (For StorageReflectSessions, this value, if non-NULL, is a pointer to the DataNode in this Session's node subtree that was matched by the paths in (msg)) |
Reimplemented in DumbReflectSession, FilterSessionFactory, ThreadWorkerSession, 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.
| 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.
| 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. |
| 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.
| 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). |
| 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.
| 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). |
| AbstractReflectSessionRef ServerComponent::GetSession | ( | uint32 | id | ) | const [protected, inherited] |
Looks up a session connected to our ReflectServer via its session ID string.
| id | The ID of the session you are looking for. |
| AbstractReflectSessionRef ServerComponent::GetSession | ( | const String & | id | ) | const [protected, inherited] |
Looks up a session connected to our ReflectServer via its session ID string.
| id | The ID string of the session you are looking for. |
| 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.
| 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.
| child | The child to place into our set of child PulseNodes. |
| status_t PulseNode::RemovePulseChild | ( | PulseNode * | child | ) | [inherited] |
Attempts to remove the given child from our set of child PulseNodes.
| child | The child to remove |
| bool PulseNode::ContainsPulseChild | ( | PulseNode * | child | ) | const [inline, inherited] |
Returns true iff the given child is in our set of child PulseNodes.
| child | the child to look for. |
Definition at line 84 of file PulseNode.h.
References PulseNode::_parent.
| uint64 PulseNode::GetCycleStartTime | ( | ) | const [inline, inherited] |
Returns the run-time at which the PulseNodeManager started calling our callbacks.
Useful for any object that wants to limit the maximum duration of its timeslice in the PulseNodeManager's event loop.
Definition at line 95 of file PulseNode.h.
| void PulseNode::SetSuggestedMaximumTimeSlice | ( | uint64 | maxUsecs | ) | [inline, inherited] |
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).
Note that this value is merely a suggestion; it remains up to the subclass's callback methods to ensure that the suggestion is actually followed.
| maxUsecs | Maximum number of microseconds that the time slice should last for. If set to MUSCLE_TIME_NEVER, that indicates that there is no suggested limit. |
Definition at line 104 of file PulseNode.h.
| uint64 PulseNode::GetSuggestedMaximumTimeSlice | ( | ) | const [inline, inherited] |
Returns the current suggested maximum duration of our time slice, or MUSCLE_TIME_NEVER if there is no suggested limit.
Default value is MUSCLE_TIME_NEVER.
Definition at line 109 of file PulseNode.h.