adchpp::Client Class Reference

The client represents one connection to a user. More...

#include <Client.h>

Inheritance diagram for adchpp::Client:
Inheritance graph
[legend]
Collaboration diagram for adchpp::Client:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::function< void(Client
&, const uint8_t *, size_t) 
DataFunction )
 Set data mode for aBytes bytes.
enum  Flag {
  FLAG_BOT = 0x01, FLAG_REGISTERED = 0x02, FLAG_OP = 0x04, FLAG_SU = 0x08, FLAG_OWNER = 0x10, FLAG_HUB = 0x20,
  FLAG_HIDDEN = 0x40, MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB | FLAG_HIDDEN, FLAG_PASSWORD = 0x100, FLAG_EXT_AWAY = 0x200, FLAG_OK_IP = 0x400, FLAG_GHOST = 0x800
}
enum  State { STATE_PROTOCOL, STATE_IDENTIFY, STATE_VERIFY, STATE_NORMAL, STATE_DATA }

Public Member Functions

ADCHPP_DLL bool addSupports (uint32_t feature)
ADCHPP_DLL void clearPluginData (const PluginDataHandle &handle) throw ()
 Clear any data referenced by the handle, calling the registered delete function.
virtual ADCHPP_DLL void disconnect (Util::Reason reason) throw ()
ADCHPP_DLL bool getAllFields (AdcCommand &cmd) const throw ()
 Add any flags that have been updated to the AdcCommand (type etc is not set).
const CIDgetCID () const
ADCHPP_DLL const std::string & getField (const char *name) const
ADCHPP_DLL const BufferPtrgetINF () const
const std::string & getIp () const throw ()
size_t getMaxCommandSize ()
virtual time_t getOverflow () const
 The time that this entity's write buffer size exceeded the maximum buffer size, 0 if no overflow.
ADCHPP_DLL void * getPluginData (const PluginDataHandle &handle) const throw ()
virtual size_t getQueuedBytes () const
 The number of bytes in the write buffer.
uint32_t getSID () const
State getState () const
ADCHPP_DLL const BufferPtrgetSUP () const
ADCHPP_DLL StringList getSupportList () const
ADCHPP_DLL bool hasField (const char *name) const
ADCHPP_DLL bool hasSupport (uint32_t feature) const
virtual ADCHPP_DLL void inject (AdcCommand &cmd)
bool isAnySet (size_t aFlag) const
ADCHPP_DLL bool isFiltered (const std::string &features) const
bool isSet (size_t aFlag) const
ADCHPP_DLL bool removeSupports (uint32_t feature)
void send (const AdcCommand &cmd)
virtual void send (const BufferPtr &command) throw ()
void setCID (const CID &cid_)
void setDataMode (const DataFunction &handler, int64_t aBytes)
ADCHPP_DLL void setField (const char *name, const std::string &value)
ADCHPP_DLL void setFlag (size_t aFlag)
void setMaxCommandSize (size_t newSize)
ADCHPP_DLL void setPluginData (const PluginDataHandle &handle, void *data) throw ()
 Set PSD (plugin specific data).
void setState (State state_)
ADCHPP_DLL void unsetFlag (size_t aFlag)
ADCHPP_DLL void updateFields (const AdcCommand &cmd)
ADCHPP_DLL void updateSupports (const AdcCommand &cmd) throw ()

Static Public Member Functions

static Clientcreate (const ManagedSocketPtr &ms_, uint32_t sid_) throw ()
static size_t getDefaultMaxCommandSize ()
static void setDefaultMaxCommandSize (size_t newSize)

Protected Types

typedef std::map
< PluginDataHandle, void * > 
PluginDataMap

Protected Attributes

CID cid
FieldMap fields
 INF fields.
std::vector< uint32_t > filters
 INF SU.
Flags flags
BufferPtr INF
 Latest INF cached.
PluginDataMap pluginData
 Plugin data, see PluginManager::registerPluginData.
uint32_t sid
State state
BufferPtr SUP
 Latest SUP cached.
std::vector< uint32_t > supports
 SUP items.

Private Member Functions

 Client (uint32_t sid_) throw ()
void onConnected () throw ()
void onData (const BufferPtr &) throw ()
void onFailed (const boost::system::error_code &ec) throw ()
void setSocket (const ManagedSocketPtr &aSocket) throw ()
virtual ~Client ()

Private Attributes

BufferPtr buffer
int64_t dataBytes
DataFunction dataHandler
bool disconnecting
size_t maxCommandSize
ManagedSocketPtr socket

Static Private Attributes

static size_t defaultMaxCommandSize = 16 * 1024

Detailed Description

The client represents one connection to a user.

Definition at line 35 of file Client.h.


Member Typedef Documentation

typedef std::function<void (Client&, const uint8_t*, size_t) adchpp::Client::DataFunction)

Set data mode for aBytes bytes.

May only be called from on(ClientListener::Command...).

Definition at line 51 of file Client.h.

typedef std::map<PluginDataHandle, void*> adchpp::Entity::PluginDataMap [protected, inherited]

Definition at line 141 of file Entity.h.


Member Enumeration Documentation

enum adchpp::Entity::Flag [inherited]
Enumerator:
FLAG_BOT 
FLAG_REGISTERED 
FLAG_OP 
FLAG_SU 
FLAG_OWNER 
FLAG_HUB 
FLAG_HIDDEN 
MASK_CLIENT_TYPE 
FLAG_PASSWORD 
FLAG_EXT_AWAY 

Extended away, no need to send msg.

FLAG_OK_IP 

Plugins can use these flags to disable various checks.

Bypass ip check

FLAG_GHOST 

This entity is now a ghost being disconnected, totally ignored by ADCH++.

Definition at line 45 of file Entity.h.

enum adchpp::Entity::State [inherited]
Enumerator:
STATE_PROTOCOL 

Initial protocol negotiation (wait for SUP).

STATE_IDENTIFY 

Identify the connecting client (wait for INF).

STATE_VERIFY 

Verify the client (wait for PAS).

STATE_NORMAL 

Normal operation.

STATE_DATA 

Binary data transfer.

Definition at line 32 of file Entity.h.


Constructor & Destructor Documentation

adchpp::Client::Client ( uint32_t  sid_  )  throw () [private]

Definition at line 38 of file Client.cpp.

adchpp::Client::~Client (  )  [private, virtual]

Definition at line 42 of file Client.cpp.


Member Function Documentation

bool adchpp::Entity::addSupports ( uint32_t  feature  )  [inherited]

Definition at line 93 of file Entity.cpp.

References adchpp::Entity::SUP, and adchpp::Entity::supports.

Referenced by adchpp::ClientManager::ClientManager().

Here is the caller graph for this function:

void adchpp::Entity::clearPluginData ( const PluginDataHandle handle  )  throw () [inherited]

Clear any data referenced by the handle, calling the registered delete function.

Definition at line 186 of file Entity.cpp.

Client * adchpp::Client::create ( const ManagedSocketPtr ms_,
uint32_t  sid_ 
) throw () [static]

Definition at line 32 of file Client.cpp.

References c, ms, and setSocket().

Referenced by adchpp::ClientManager::handleIncoming().

Here is the call graph for this function:

Here is the caller graph for this function:

void adchpp::Client::disconnect ( Util::Reason  reason  )  throw () [virtual]
bool adchpp::Entity::getAllFields ( AdcCommand cmd  )  const throw () [inherited]

Add any flags that have been updated to the AdcCommand (type etc is not set).

Definition at line 69 of file Entity.cpp.

References adchpp::AdcCommand::fromField().

Referenced by adchpp::Entity::getINF().

Here is the call graph for this function:

Here is the caller graph for this function:

const CID& adchpp::Entity::getCID (  )  const [inline, inherited]

Definition at line 119 of file Entity.h.

Referenced by adchpp::ClientManager::regBot(), adchpp::ClientManager::removeEntity(), and adchpp::ClientManager::verifyCID().

Here is the caller graph for this function:

static size_t adchpp::Client::getDefaultMaxCommandSize (  )  [inline, static]

Definition at line 55 of file Client.h.

const std::string & adchpp::Entity::getField ( const char *  name  )  const [inherited]

Definition at line 37 of file Entity.cpp.

References adchpp::Util::emptyString, adchpp::Entity::fields, and adchpp::AdcCommand::toField().

Referenced by adchpp::ClientManager::regBot(), adchpp::ClientManager::removeEntity(), and adchpp::ClientManager::verifyNick().

Here is the call graph for this function:

Here is the caller graph for this function:

const BufferPtr & adchpp::Entity::getINF (  )  const [inherited]

Definition at line 84 of file Entity.cpp.

References adchpp::Entity::getAllFields(), adchpp::AdcCommand::getBuffer(), adchpp::Entity::getSID(), adchpp::AdcCommand::HUB_SID, adchpp::Entity::INF, adchpp::AdcCommand::TYPE_BROADCAST, and adchpp::AdcCommand::TYPE_INFO.

Referenced by adchpp::ClientManager::enterNormal().

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& adchpp::Client::getIp (  )  const throw () [inline]

Definition at line 45 of file Client.h.

Referenced by adchpp::ClientManager::verifyIp().

Here is the caller graph for this function:

size_t adchpp::Client::getMaxCommandSize (  )  [inline]

Definition at line 58 of file Client.h.

virtual time_t adchpp::Client::getOverflow (  )  const [inline, virtual]

The time that this entity's write buffer size exceeded the maximum buffer size, 0 if no overflow.

Reimplemented from adchpp::Entity.

Definition at line 61 of file Client.h.

void * adchpp::Entity::getPluginData ( const PluginDataHandle handle  )  const throw () [inherited]
Parameters:
handle Plugin data handle, as returned by PluginManager::registerPluginData
Returns:
Value stored, NULL if none found

Definition at line 181 of file Entity.cpp.

virtual size_t adchpp::Client::getQueuedBytes (  )  const [inline, virtual]

The number of bytes in the write buffer.

Reimplemented from adchpp::Entity.

Definition at line 60 of file Client.h.

uint32_t adchpp::Entity::getSID (  )  const [inline, inherited]
State adchpp::Entity::getState (  )  const [inline, inherited]
const BufferPtr & adchpp::Entity::getSUP (  )  const [inherited]
StringList adchpp::Entity::getSupportList (  )  const [inherited]

Definition at line 105 of file Entity.cpp.

References adchpp::AdcCommand::fromFourCC(), and adchpp::Entity::supports.

Here is the call graph for this function:

bool adchpp::Entity::hasField ( const char *  name  )  const [inherited]

Definition at line 42 of file Entity.cpp.

References adchpp::Entity::fields, and adchpp::AdcCommand::toField().

Referenced by adchpp::ClientManager::verifyIp().

Here is the call graph for this function:

Here is the caller graph for this function:

bool adchpp::Entity::hasSupport ( uint32_t  feature  )  const [inherited]

Definition at line 138 of file Entity.cpp.

References adchpp::Entity::supports.

Referenced by adchpp::ClientManager::verifySUP().

Here is the caller graph for this function:

void adchpp::Entity::inject ( AdcCommand cmd  )  [virtual, inherited]

Definition at line 33 of file Entity.cpp.

References adchpp::Singleton< T >::getInstance().

Here is the call graph for this function:

bool adchpp::Entity::isAnySet ( size_t  aFlag  )  const [inline, inherited]

Definition at line 126 of file Entity.h.

bool adchpp::Entity::isFiltered ( const std::string &  features  )  const [inherited]

Definition at line 157 of file Entity.cpp.

References adchpp::Entity::filters, and adchpp::AdcCommand::toFourCC().

Here is the call graph for this function:

bool adchpp::Entity::isSet ( size_t  aFlag  )  const [inline, inherited]

Definition at line 125 of file Entity.h.

Referenced by adchpp::ClientManager::removeEntity(), and adchpp::ClientManager::verifyIp().

Here is the caller graph for this function:

void adchpp::Client::onConnected (  )  throw () [private]

Definition at line 78 of file Client.cpp.

void adchpp::Client::onData ( const BufferPtr buf  )  throw () [private]

Definition at line 82 of file Client.cpp.

void adchpp::Client::onFailed ( const boost::system::error_code &  ec  )  throw () [private]

Definition at line 167 of file Client.cpp.

bool adchpp::Entity::removeSupports ( uint32_t  feature  )  [inherited]

Definition at line 114 of file Entity.cpp.

References adchpp::Entity::SUP, and adchpp::Entity::supports.

void adchpp::Entity::send ( const AdcCommand cmd  )  [inline, inherited]

Definition at line 71 of file Entity.h.

References adchpp::AdcCommand::getBuffer(), and adchpp::Entity::send().

Referenced by adchpp::ClientManager::maybeSend(), adchpp::Entity::send(), adchpp::ClientManager::verifyCID(), and adchpp::ClientManager::verifyOverflow().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void adchpp::Client::send ( const BufferPtr command  )  throw () [inline, virtual]
void adchpp::Entity::setCID ( const CID cid_  )  [inline, inherited]

Definition at line 120 of file Entity.h.

Referenced by adchpp::Bot::Bot(), and adchpp::ClientManager::verifyCID().

Here is the caller graph for this function:

void adchpp::Client::setDataMode ( const DataFunction handler,
int64_t  aBytes 
) [inline]

Definition at line 52 of file Client.h.

static void adchpp::Client::setDefaultMaxCommandSize ( size_t  newSize  )  [inline, static]

Definition at line 54 of file Client.h.

void adchpp::Entity::setField ( const char *  name,
const std::string &  value 
) [inherited]
void adchpp::Entity::setFlag ( size_t  aFlag  )  [inherited]

Definition at line 196 of file Entity.cpp.

References adchpp::Entity::flags, adchpp::Flags::getFlags(), adchpp::Entity::MASK_CLIENT_TYPE, adchpp::Entity::setField(), adchpp::Flags::setFlag(), and adchpp::Util::toString().

Referenced by adchpp::Bot::Bot(), adchpp::Hub::Hub(), and adchpp::ClientManager::verifyCID().

Here is the call graph for this function:

Here is the caller graph for this function:

void adchpp::Client::setMaxCommandSize ( size_t  newSize  )  [inline]

Definition at line 57 of file Client.h.

void adchpp::Entity::setPluginData ( const PluginDataHandle handle,
void *  data 
) throw () [inherited]

Set PSD (plugin specific data).

This allows a plugin to store arbitrary per-client data, and retrieve it later on. The life cycle of the data follows that of the client unless explicitly removed. Any data referenced by the plugin will have its delete function called when the Entity is deleted.

Parameters:
id Id as retrieved from PluginManager::getPluginId()
data Data to store, this can be pretty much anything

Definition at line 176 of file Entity.cpp.

void adchpp::Client::setSocket ( const ManagedSocketPtr aSocket  )  throw () [private]

Definition at line 70 of file Client.cpp.

Referenced by create().

Here is the caller graph for this function:

void adchpp::Entity::setState ( State  state_  )  [inline, inherited]

Definition at line 123 of file Entity.h.

Referenced by adchpp::ClientManager::setState().

Here is the caller graph for this function:

void adchpp::Entity::unsetFlag ( size_t  aFlag  )  [inherited]
void adchpp::Entity::updateFields ( const AdcCommand cmd  )  [inherited]

Definition at line 75 of file Entity.cpp.

References dcassert, adchpp::AdcCommand::getCommand(), adchpp::AdcCommand::getParameters(), and adchpp::Entity::setField().

Referenced by adchpp::ClientManager::verifyINF().

Here is the call graph for this function:

Here is the caller graph for this function:

void adchpp::Entity::updateSupports ( const AdcCommand cmd  )  throw () [inherited]

Definition at line 142 of file Entity.cpp.

References adchpp::AdcCommand::toFourCC().

Referenced by adchpp::ClientManager::verifySUP().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 70 of file Client.h.

CID adchpp::Entity::cid [protected, inherited]

Definition at line 143 of file Entity.h.

int64_t adchpp::Client::dataBytes [private]

Definition at line 72 of file Client.h.

Definition at line 76 of file Client.h.

size_t adchpp::Client::defaultMaxCommandSize = 16 * 1024 [static, private]

Definition at line 63 of file Client.h.

Definition at line 68 of file Client.h.

FieldMap adchpp::Entity::fields [protected, inherited]

INF fields.

Definition at line 155 of file Entity.h.

Referenced by adchpp::Entity::getField(), adchpp::Entity::hasField(), and adchpp::Entity::setField().

std::vector<uint32_t> adchpp::Entity::filters [protected, inherited]

INF SU.

Definition at line 152 of file Entity.h.

Referenced by adchpp::Entity::isFiltered(), and adchpp::Entity::setField().

Flags adchpp::Entity::flags [protected, inherited]

Definition at line 145 of file Entity.h.

Referenced by adchpp::Entity::setFlag(), and adchpp::Entity::unsetFlag().

BufferPtr adchpp::Entity::INF [mutable, protected, inherited]

Latest INF cached.

Definition at line 161 of file Entity.h.

Referenced by adchpp::Entity::getINF(), and adchpp::Entity::setField().

Definition at line 74 of file Client.h.

PluginDataMap adchpp::Entity::pluginData [protected, inherited]

Plugin data, see PluginManager::registerPluginData.

Definition at line 158 of file Entity.h.

Referenced by adchpp::Entity::~Entity().

uint32_t adchpp::Entity::sid [protected, inherited]

Definition at line 144 of file Entity.h.

Definition at line 71 of file Client.h.

State adchpp::Entity::state [protected, inherited]

Definition at line 146 of file Entity.h.

BufferPtr adchpp::Entity::SUP [mutable, protected, inherited]

Latest SUP cached.

Definition at line 164 of file Entity.h.

Referenced by adchpp::Entity::addSupports(), adchpp::Entity::getSUP(), and adchpp::Entity::removeSupports().

std::vector<uint32_t> adchpp::Entity::supports [protected, inherited]
Generated on Sat Nov 27 23:38:33 2010 for adchpp by  doxygen 1.6.3