ConnectX 3.0
ConnectX Game Suite
Loading...
Searching...
No Matches
Connection Class Reference

#include <connection.hpp>

Inheritance diagram for Connection:
Collaboration diagram for Connection:

Public Types

using MessageCallback = std::function< void(const std::string &)>
 
using DisconnectCallback = std::function< void()>
 

Public Member Functions

 Connection (sockpp::tcp_socket socket, uint32_t id)
 
 ~Connection ()
 
void start ()
 
bool send (const std::string &message)
 
void close ()
 
bool isOpen () const
 
uint32_t getId () const
 
void setMessageCallback (MessageCallback callback)
 
void setDisconnectCallback (DisconnectCallback callback)
 

Detailed Description

Represents a single client connection Handles reading/writing messages to/from a client

Member Typedef Documentation

◆ DisconnectCallback

using Connection::DisconnectCallback = std::function<void()>

◆ MessageCallback

using Connection::MessageCallback = std::function<void(const std::string &)>

Constructor & Destructor Documentation

◆ Connection()

Connection::Connection ( sockpp::tcp_socket  socket,
uint32_t  id 
)
explicit

◆ ~Connection()

Connection::~Connection ( )

Member Function Documentation

◆ close()

void Connection::close ( )

Close the connection

◆ getId()

uint32_t Connection::getId ( ) const
inline

Get connection ID

◆ isOpen()

bool Connection::isOpen ( ) const
inline

Check if connection is open

◆ send()

bool Connection::send ( const std::string &  message)

Send a message to the client

◆ setDisconnectCallback()

void Connection::setDisconnectCallback ( DisconnectCallback  callback)
inline

Set callback for disconnection

◆ setMessageCallback()

void Connection::setMessageCallback ( MessageCallback  callback)
inline

Set callback for received messages

◆ start()

void Connection::start ( )

Start reading from this connection (blocking in thread)


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