Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CODEX_KeyService::ClientActivity Class Reference

This class manages connections to clients. More...

#include <ClientActivity.h>

Inheritance diagram for CODEX_KeyService::ClientActivity:

Inheritance graph
[legend]
Collaboration diagram for CODEX_KeyService::ClientActivity:

Collaboration graph
[legend]
List of all members.

Public Types

typedef CODEX_Events::DeadPileType DeadPileType
 Convenient typedef.
typedef CODEX_Events::QType QType
 Convenient typedef.

Public Member Functions

 ClientActivity (int port, const CODEX_Quorum::SocketBuilder &socketBuilder, DeadPileType &deadPile, QType &eventQueue, ClientMessageHandler *destination, CODEX_Quorum::SocketBase *socket=NULL)
 Create a new ClientActivity.
virtual ~ClientActivity ()
 Virtual destructor.
void processRequest (CODEX_Quorum::SocketBase::StateType s)
 When a LocalServer has activity on its socket, this method is called.
bool handler (CODEX_Events::EventAck &event)
 Override the default acknowledgment handler.
bool handler (CODEX_Events::CloseEvent &event)
bool handler (ClientResponseEvent< SignedPublicKeyMsg > &event)
 Abstract handler for a signed PublicKeyMsg.
bool handler (ClientResponseEvent< SignedBoundNameMsg > &event)
 Abstract handler for a signed BoundNameMsg.
bool handler (ClientResponseEvent< SignedKeyStoredMsg > &event)
 Abstract handler for a signed KeyStoredMsg.
bool handler (ClientResponseEvent< SignedBlindKeyMsg > &event)
 Abstract handler for a signed BlindKeyMsg.
void close ()
 Hook to tell the activity that it needs to be closed.
virtual bool handler (CloseEvent &event)=0
 Abstract handler for CloseEvent%s.
virtual bool handler (EventAck &event)
 The base class is responsible for handling acknowledgements, which are relevant to whether the Activity is ready for deletion.
virtual void enable ()
 Create a socket and begin listening.
virtual void disable ()
 Stop listening and destroy the open socket.
int port () const
 The port on which the server is listening.
virtual int set_fd (fd_set *fd_bitmap, SocketBase::StateType s)
 Set the bitmap for this socket.
virtual bool isset_fd (const fd_set *fd_bitmap, SocketBase::StateType s)
 Whether the bitmap is set for this socket.
virtual void processRequest (SocketBase::StateType s)=0
 Process incoming requests.

Protected Member Functions

void sendEvent (EventBase *event, Activity *source, bool failure=false)
void enableTerminate ()
 This method should be called when an Activity has received a CloseEvent or other indicator that it is no longer needed.
SocketBasesocket () const
 Returns the socket on which this server is listening.
const SocketBuilder & builder () const
 Returns the SocketBuilder for this server.
void setSocket (SocketBase *socket)
 Set a SocketBase for this server.

Protected Attributes

DeadPileTypem_deadPile
 The pile of Activity%s to be garbage-collected.
QTypem_queue
 The event queue.

Detailed Description

This class manages connections to clients.

It is an Activity because it emits and handles events, notably dispatching incoming and outgoing messages for its client. It is a LocalServer because it maintains a socket connected to a remote process, the client. As a LocalServer, it has all of the functionality needed for detecting when a socket is ready for reading or writing.

Definition at line 48 of file ClientActivity.h.


Constructor & Destructor Documentation

ClientActivity::ClientActivity int  port,
const CODEX_Quorum::SocketBuilder socketBuilder,
DeadPileType deadPile,
QType eventQueue,
ClientMessageHandler destination,
CODEX_Quorum::SocketBase socket = NULL
 

Create a new ClientActivity.

Parameters:
port The port on which this server is listening. This is irrelevant for this class, but is needed for the LocalServer base class.
socketBuilder The object with which to construct a new socket. Likely to be irrelevant for this class, but it is needed for the LocalServer base class.
deadPile The queue of Activities that are ready to be garbage-collected. The Activity adds itself to the queue when enableTerminate() has been called and no more messages are outstanding.
eventQueue The queue of events to be handled.
destination The next Activity to which events are sent.
socket This will most likely be the socket created by ClientServer::accept().

Definition at line 35 of file ClientActivity.cc.

References CODEX_KeyService::StateInfo::addClient(), CODEX_Server::ServerState::instance(), CODEX_KeyService::StateInfo::instance(), and CODEX_Quorum::LocalServer::setSocket().


Member Function Documentation

const SocketBuilder& CODEX_Quorum::LocalServer::builder  )  const [inline, protected, inherited]
 

Returns the SocketBuilder for this server.

Definition at line 120 of file LocalServer.h.

Referenced by CODEX_KeyService::ClientServer::processRequest().

void LocalServer::disable  )  [virtual, inherited]
 

Stop listening and destroy the open socket.

Derived classes needing to clean up any state on shutdown should reimplement this method. This base-class version should be called explicitly, to ensure the necessary base class cleanup.

Reimplemented in CODEX_Server::InternalVerifier.

Definition at line 53 of file LocalServer.cc.

Referenced by CODEX_Server::InternalVerifier::disable().

void LocalServer::enable  )  [virtual, inherited]
 

Create a socket and begin listening.

Derived classes should reimplement this to perform other service initialization tasks needed. This base-class version should be called explicitly, to ensure the necessary base class initialization.

Definition at line 41 of file LocalServer.cc.

References CODEX_Quorum::SocketBase::setup().

void Activity::enableTerminate  )  [protected, inherited]
 

This method should be called when an Activity has received a CloseEvent or other indicator that it is no longer needed.

Actual termination will not occur until there are no remaining events outstanding (unacknowledged).

Definition at line 63 of file Activity.cc.

Referenced by handler(), and processRequest().

bool Activity::handler EventAck event  )  [virtual, inherited]
 

The base class is responsible for handling acknowledgements, which are relevant to whether the Activity is ready for deletion.

If a derived class reimpliments this method, it must call this version explicitly.

Definition at line 39 of file Activity.cc.

Referenced by CODEX_Events::EventAck::handle(), and handler().

bool ClientActivity::handler CODEX_Events::EventAck event  ) 
 

Override the default acknowledgment handler.

This activity might receive negative acknowledgments, at which point it should terminate the connection.

Definition at line 177 of file ClientActivity.cc.

References CODEX_Events::Activity::enableTerminate(), CODEX_Events::Activity::handler(), and CODEX_Events::Activity::sendEvent().

bool LocalServer::isset_fd const fd_set *  fd_bitmap,
SocketBase::StateType  s
[virtual, inherited]
 

Whether the bitmap is set for this socket.

Some types of sockets may need to know the operation being tested.

Definition at line 76 of file LocalServer.cc.

References CODEX_Quorum::SocketBase::isset_fd().

virtual void CODEX_Quorum::LocalServer::processRequest SocketBase::StateType  s  )  [pure virtual, inherited]
 

Process incoming requests.

Derived classes must implement this routine, which is called whenever a connection is made.

Attention:
No further connections may be handled, nor any other actions taken, until this function returns. Consequently, if you do not want your program to block on a request, you must implement some concurrency mechanism, such as an event model or threads. This class makes no assumptions about concurrency.

Implemented in CODEX_Quorum::EchoServer.

void ClientActivity::processRequest CODEX_Quorum::SocketBase::StateType  s  ) 
 

When a LocalServer has activity on its socket, this method is called.

Because we are using an event architecture to achieve concurrency, this method should be fairly light-weight (as should all). For incoming data, it performs the necessary type determinations to create events for the polymorphic ClientMessageHandler::handler() method.

Definition at line 81 of file ClientActivity.cc.

References CODEX_Quorum::Message::buffer(), CODEX_Events::Activity::enableTerminate(), CODEX_Quorum::Message::length(), CODEX_Events::Activity::sendEvent(), CODEX_Quorum::LocalServer::socket(), and CODEX_KeyService::ClientMessageEventBase::unmarshal().

void Activity::sendEvent EventBase event,
Activity source,
bool  failure = false
[protected, inherited]
 

Parameters:
event New event to be added to the queue
source Source of event just handled, to which an acknowledgement should be sent. This is accessed by the method EventBase::source().
failure Is the acknowledgment a negative ack?

Definition at line 49 of file Activity.cc.

References CODEX_Events::Activity::m_queue.

Referenced by CODEX_APSS::InitActivity::addEvidence(), CODEX_APSS::MessageDeliverer::broadcast(), close(), CODEX_Server::UnicastRequestHandler::handler(), CODEX_Server::ShareLabelChallengeHandler::handler(), CODEX_Server::ServerResponseHandler::handler(), CODEX_Server::QuorumBuilderAct::handler(), CODEX_APSS::MessageVerifier::handler(), CODEX_APSS::MessageProcessor::handler(), CODEX_APSS::InitActivity::handler(), CODEX_KeyService::DelegateResponseVerifier::handler(), CODEX_KeyService::DelegateRequestDistributor::handler(), CODEX_KeyService::ClientResponseSigner::handler(), CODEX_KeyService::ClientMessageVerifier::handler(), CODEX_KeyService::ClientMessageSigner::handler(), CODEX_KeyService::ClientMessageAbsorber::handler(), handler(), CODEX_Server::BroadcastRequestHandler::handler(), CODEX_KeyService::VerifyWriteCallback::operator()(), CODEX_KeyService::SignWriteCallback::operator()(), CODEX_KeyService::SignReadCallback::operator()(), CODEX_KeyService::SignCreateCallback::operator()(), CODEX_APSS::MessageParser::operator()(), CODEX_KeyService::ClientWriteCallback::operator()(), CODEX_KeyService::ClientResponseParser::operator()(), CODEX_KeyService::ClientReadCallback::operator()(), CODEX_KeyService::ClientMessageParser::operator()(), CODEX_KeyService::ClientCreateCallback::operator()(), processRequest(), CODEX_Server::QuorumBuilderAct::QuorumBuilderAct(), CODEX_APSS::MessageDeliverer::sendTo(), CODEX_Server::ShareLabelChallengeHandler::ShareLabelChallengeHandler(), and CODEX_APSS::TriggerActivity::TriggerActivity().

int LocalServer::set_fd fd_set *  fd_bitmap,
SocketBase::StateType  s
[virtual, inherited]
 

Set the bitmap for this socket.

Some types of sockets may need to know the operation being tested.

Definition at line 69 of file LocalServer.cc.

References CODEX_Quorum::SocketBase::set_fd().

void CODEX_Quorum::LocalServer::setSocket SocketBase socket  )  [inline, protected, inherited]
 

Set a SocketBase for this server.

Useful for servers that clone themselves.

Definition at line 126 of file LocalServer.h.

References CODEX_Quorum::LocalServer::socket().

Referenced by ClientActivity(), and CODEX_Server::InternalVerifier::InternalVerifier().


The documentation for this class was generated from the following files:
Generated on Fri May 6 17:42:10 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1