InspIRCd  3.0
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
ClientProtocol::Message Class Reference

#include <clientprotocol.h>

Inheritance diagram for ClientProtocol::Message:
ClientProtocol::MessageSource ClientProtocol::Messages::Error ClientProtocol::Messages::Invite ClientProtocol::Messages::Join ClientProtocol::Messages::Kick ClientProtocol::Messages::Mode ClientProtocol::Messages::Nick ClientProtocol::Messages::Numeric ClientProtocol::Messages::Part ClientProtocol::Messages::Ping ClientProtocol::Messages::Pong ClientProtocol::Messages::Privmsg ClientProtocol::Messages::Quit ClientProtocol::Messages::Topic

Classes

class  Param
 
struct  SerializedInfo
 

Public Types

typedef std::vector< ParamParamList
 

Public Member Functions

 Message (const char *cmd, User *Sourceuser=NULL)
 
 Message (const char *cmd, const std::string &Sourcestr, User *Sourceuser=NULL)
 
const ParamList & GetParams () const
 
const TagMapGetTags () const
 
const char * GetCommand () const
 
void PushParam (const char *str)
 
void PushParam (const std::string &str)
 
void PushParamRef (const std::string &str)
 
void PushParamPlaceholder ()
 
void ReplaceParam (unsigned int index, const char *str)
 
void ReplaceParam (unsigned int index, const std::string &str)
 
void ReplaceParamRef (unsigned int index, const std::string &str)
 
void AddTag (const std::string &tagname, MessageTagProvider *tagprov, const std::string &val, void *tagdata=NULL)
 
void AddTags (const ClientProtocol::TagMap &newtags)
 
const SerializedMessage & GetSerialized (const SerializedInfo &serializeinfo) const
 
void ClearParams ()
 
void InvalidateCache ()
 
void CopyAll ()
 
void SetSideEffect (bool Sideeffect)
 
bool IsSideEffect () const
 
- Public Member Functions inherited from ClientProtocol::MessageSource
 MessageSource (User *Sourceuser=NULL)
 
 MessageSource (const std::string &Sourcestr, User *Sourceuser=NULL)
 
const std::string * GetSource () const
 
UserGetSourceUser () const
 
void SetSourceUser (User *Sourceuser)
 
void SetSource (const std::string &Sourcestr, User *Sourceuser=NULL)
 
void SetSource (const MessageSource &other)
 

Protected Member Functions

void SetCommand (const char *cmd)
 

Friends

class Serializer
 

Detailed Description

Outgoing client protocol message. Represents a high level client protocol message which is turned into raw or wire format by a Serializer. Messages can be serialized into different format by different serializers.

Messages are created on demand and are disposed of after they have been sent.

All messages have a command name, a list of parameters and a map of tags, the last two can be empty. They also always have a source, see class MessageSource.

Constructor & Destructor Documentation

◆ Message() [1/2]

ClientProtocol::Message::Message ( const char *  cmd,
User Sourceuser = NULL 
)
inline

Constructor.

Parameters
cmdCommand name, e.g. "JOIN", "NICK". May be NULL. If NULL, the command must be set with SetCommand() before the message is serialized.
SourceuserSee the one parameter constructor of MessageSource for description.

◆ Message() [2/2]

ClientProtocol::Message::Message ( const char *  cmd,
const std::string &  Sourcestr,
User Sourceuser = NULL 
)
inline

Constructor.

Parameters
cmdCommand name, e.g. "JOIN", "NICK". May be NULL. If NULL, the command must be set with SetCommand() before the message is serialized.
SourcestrSee the two parameter constructor of MessageSource for description. Must remain valid as long as this object is alive.
SourceuserSee the two parameter constructor of MessageSource for description.

Member Function Documentation

◆ AddTag()

void ClientProtocol::Message::AddTag ( const std::string &  tagname,
MessageTagProvider tagprov,
const std::string &  val,
void *  tagdata = NULL 
)
inline

Add a tag.

Parameters
tagnameRaw name of the tag to use in the protocol.
tagprovProvider of the tag.
valTag value. If empty no value will be sent with the tag.
tagdataTag provider specific data, will be passed to MessageTagProvider::ShouldSendTag(). Optional, defaults to NULL.

◆ AddTags()

void ClientProtocol::Message::AddTags ( const ClientProtocol::TagMap newtags)
inline

Add all tags in a TagMap to the tags in this message. Existing tags will not be overwritten.

Parameters
newtagsNew tags to add.

◆ ClearParams()

void ClientProtocol::Message::ClearParams ( )
inline

Clear the parameter list and tags.

◆ GetCommand()

const char* ClientProtocol::Message::GetCommand ( ) const
inline

Get the command string.

Returns
Command string, e.g. "NICK", "001".

◆ GetParams()

const ParamList& ClientProtocol::Message::GetParams ( ) const
inline

Get the parameters of this message.

Returns
List of parameters.

◆ GetSerialized()

const ClientProtocol::SerializedMessage & ClientProtocol::Message::GetSerialized ( const SerializedInfo serializeinfo) const

Get the message in a serialized form.

Parameters
serializeinfoInformation about which exact serialized form of the message is the caller asking for (which serializer to use and which tags to include).
Returns
Serialized message according to serializeinfo. The returned reference remains valid until the next call to this method.

◆ GetTags()

const TagMap& ClientProtocol::Message::GetTags ( ) const
inline

Get a map of tags attached to this message. The map contains the tag providers that attached the tag to the message.

Returns
Map of tags.

◆ InvalidateCache()

void ClientProtocol::Message::InvalidateCache ( )
inline

Remove all serialized messages. If a parameter is changed after the message has been sent at least once, this method must be called before serializing the message again to ensure the cache won't contain stale data.

◆ PushParam() [1/2]

void ClientProtocol::Message::PushParam ( const char *  str)
inline

Add a parameter to the parameter list.

Parameters
strString to add, will be copied.

◆ PushParam() [2/2]

void ClientProtocol::Message::PushParam ( const std::string &  str)
inline

Add a parameter to the parameter list.

Parameters
strString to add, will be copied.

◆ PushParamPlaceholder()

void ClientProtocol::Message::PushParamPlaceholder ( )
inline

Add a placeholder parameter to the parameter list. Placeholder parameters must be filled in later with actual parameters using ReplaceParam() or ReplaceParamRef().

◆ PushParamRef()

void ClientProtocol::Message::PushParamRef ( const std::string &  str)
inline

Add a parameter to the parameter list.

Parameters
strString to add. The string will NOT be copied, it must remain alive until ClearParams() is called or until the object is destroyed.

◆ ReplaceParam() [1/2]

void ClientProtocol::Message::ReplaceParam ( unsigned int  index,
const char *  str 
)
inline

Replace a parameter or a placeholder that is already in the parameter list.

Parameters
indexIndex of the parameter to replace. Must be less than GetParams().size().
strString to replace the parameter or placeholder with, will be copied.

◆ ReplaceParam() [2/2]

void ClientProtocol::Message::ReplaceParam ( unsigned int  index,
const std::string &  str 
)
inline

Replace a parameter or a placeholder that is already in the parameter list.

Parameters
indexIndex of the parameter to replace. Must be less than GetParams().size().
strString to replace the parameter or placeholder with, will be copied.

◆ ReplaceParamRef()

void ClientProtocol::Message::ReplaceParamRef ( unsigned int  index,
const std::string &  str 
)
inline

Replace a parameter or a placeholder that is already in the parameter list.

Parameters
indexIndex of the parameter to replace. Must be less than GetParams().size().
strString to replace the parameter or placeholder with. The string will NOT be copied, it must remain alive until ClearParams() is called or until the object is destroyed.

◆ SetCommand()

void ClientProtocol::Message::SetCommand ( const char *  cmd)
inlineprotected

Set command string.

Parameters
cmdCommand string to set.

The documentation for this class was generated from the following files: