-
class
ReflectServer
(Return to index)
-
This class represents a reflection server: It runs on a centrally located machine,and many clients may connect to it simultaneously. This server can then redirect messagesuploaded by any client to other clients in a somewhat efficient manner.
Type:
Include file:
../../reflector/ReflectServer.h
Synopsis:
Public methods:
- public virtual void
Cleanup ()
Should be called just before the ReflectServer is to be destroyed.
this in a good place to put any cleanup code. Be sure
to call Cleanup() of your parent class as well!
(We can't just do this in the destructor, as some cleanup
relies on the subclass still being functional, which it isn't
when our destructor gets called!)
- public virtual status_t
ReadyToRun ()
Called after the server is set up, but just before accepting any connections.
Should return B_NO_ERROR if it's okay to continue, or B_ERROR to abort.
Default implementation returns B_NO_ERROR.
- public
ReflectServer ()
- public virtual status_t
ServerProcessLoop (ReflectSessionFactoryFunc createSessionFunc, short acceptPort = 2960)
The main loop for the message reflection server.
Returns B_ERROR if there was a problem setting up. This method will not return until the server stops running (usually due to an error)
(acceptPort) is the port the server will listen on.
(createSessionFunc) should be a function of the form:
AbstractReflectSession * MyFunc();
that returns a new AbstractReflectSession object to be used for communicating with
the given socket. The object this function returns determines the semantics of the server.
Most non-abstract ReflectSession classes come with such a function.
- public
~ReflectServer ()
Protected methods:
- protected virtual status_t
AddNewSession (AbstractReflectSessionRef ref, int socket)
Adds a new session that uses the given socket for I/O.
If (socket) is -1, no TCP connection will be used.
- protected virtual const struct timeval *
GetPulseRate ()
May be overridden to return a pointer for a time interval that determines
the time interval between calls to our Pulse() method. By default, this
method returns NULL, meaning that Pulse() is never called. GetPulseRate()
will be called repeatedly, so that you can vary the pulse rate if you wish.
- protected virtual const char *
GetServerName () const
Returns a human-readable string that describes the type of server that
is running. Default implementation returns "MUSCLE".
- protected PortableQueue<AbstractReflectSessionRef> &
GetSessionsList ()
Returns our contained list of active sessions.
- protected virtual void
Pulse ()
If GetPulseRate() was overridden, then this callback may be called at
intervals. Default implementation does nothing.
Friend methods: