TT Client Library 1.0.0
C++ library for Tandem Tales clients.
Loading...
Searching...
No Matches
tt::Message Class Referenceabstract

A message is information sent to or from a server in JSON format. More...

#include <tt/io/Message.h>

Inheritance diagram for tt::Message:

Public Member Functions

 Message ()
 Constructs a message.
const Client * getClient () const
 Returns the tt::Client who sent this message, or null if this message was sent by the server.
void setClient (const Client *client)
 Sets the tt::Client who sent this message.
virtual std::string type () const =0
 Type used for JSON deserialization.
virtual std::string toString () const
 Returns a string representation of this object.

Friends

std::ostream & operator<< (std::ostream &os, const Message &a)
 Override stream insertion operator to allow printing the Message class.

Detailed Description

A message is information sent to or from a server in JSON format.

Each message type has a to/from JSON function associated with it from the Nlohmann JSON Library.

Author
Gage Birchmeier

Member Function Documentation

◆ getClient()

const Client * Message::getClient ( ) const

Returns the tt::Client who sent this message, or null if this message was sent by the server.

Returns
the agent who sent the message, or null

◆ setClient()

void Message::setClient ( const Client * client)

Sets the tt::Client who sent this message.

For messages sent to the server, this method should be called soon after the message has been parsed.

Parameters
clientthe agent who sent this message

◆ toString()

std::string tt::Message::toString ( ) const
virtual

Returns a string representation of this object.

Returns
a string describing this object

Reimplemented in tt::Choice, tt::Connect, tt::End, tt::Error, tt::Join, tt::Report, tt::Start, tt::Stop, and tt::Update.

◆ type()

virtual std::string tt::Message::type ( ) const
pure virtual

Type used for JSON deserialization.

Implemented in tt::Choice, tt::Connect, tt::End, tt::Error, tt::Join, tt::Report, tt::Start, tt::Stop, and tt::Update.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Message & a )
friend

Override stream insertion operator to allow printing the Message class.

Parameters
osan output stream to insert into
aa reference to a message object
Returns
the output stream referenced

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