PandoraBotIRC
1.0.0
An irc bot that acts as a Pandora chatter bot
|
TCPConnection encapsulates a tcp connection with SFML sockets. More...
#include <TCPConnection.hpp>
Public Member Functions | |
TCPConnection () | |
Default constructor. More... | |
~TCPConnection ()=default | |
Default destructor. More... | |
TCPConnection (TCPConnection const &)=delete | |
TCPConnection & | operator= (TCPConnection const &) |
bool | connect (std::string const &server_name, std::uint16_t const &port) |
Starts up the tcp connection. More... | |
void | disconnect () |
Disconnects the tcp connection. More... | |
std::uint16_t | getLocalPort () |
Get the port to which the socket is bound locally. More... | |
std::uint16_t | getRemotePort () |
Get the port of the connected peer to which the socket is connected. More... | |
operator bool () | |
operator bool This function returns m_status. More... | |
TCPConnection & | operator<< (std::string const &rhs) |
operator << overload. More... | |
TCPConnection & | operator>> (std::string &rhs) |
operator >> overload. More... | |
TCPConnection encapsulates a tcp connection with SFML sockets.
Possible output for the above example:
pbirc::irc::TCPConnection::TCPConnection | ( | ) |
Default constructor.
Does nothing but set 'm_status' to false.
|
default |
Default destructor.
|
delete |
bool pbirc::irc::TCPConnection::connect | ( | std::string const & | server_name, |
std::uint16_t const & | port | ||
) |
Starts up the tcp connection.
[in] | server_name | domain name or IP of the server to connect to |
[in] | port | the port on the server to connect to |
void pbirc::irc::TCPConnection::disconnect | ( | ) |
Disconnects the tcp connection.
std::uint16_t pbirc::irc::TCPConnection::getLocalPort | ( | ) |
Get the port to which the socket is bound locally.
This function only forwards sf::Socket::getLocalPort().
std::uint16_t pbirc::irc::TCPConnection::getRemotePort | ( | ) |
Get the port of the connected peer to which the socket is connected.
This function only forwards sf::Socket::getRemotePort().
|
inline |
operator bool This function returns m_status.
Evaluates to true if all is good and the socket is connected. Evaluates to false if something has gone wrong or if the socket is disconnected.
TCPConnection & pbirc::irc::TCPConnection::operator<< | ( | std::string const & | rhs | ) |
operator << overload.
Is used to send data to the server. This function will disconnect and set m_status to false upon error.
Ex: connection << "This is some text that will be sent to the server";
TCPConnection& pbirc::irc::TCPConnection::operator= | ( | TCPConnection const & | ) |
TCPConnection & pbirc::irc::TCPConnection::operator>> | ( | std::string & | rhs | ) |
operator >> overload.
Is used to receive data from the server. This function will disconnect and set m_status to false upon error. The amount of data received at once by this function is limited by 'receive_buff_sz'. A received string will never be more than 'receive_buff_sz' characters in length, but may be less.
Ex: std::string data; connection >> data;