#include <socket.h>
Public Member Functions | |
Socket () | |
Constructor. | |
~Socket () | |
Destructor. | |
bool | sendStr (string) |
Send a string to the server. | |
bool | closeSock () |
Close the socket. | |
bool | connectSock (int, string, string) |
Connect the socket to the server. | |
bool | getState () |
Get connection state. | |
string | getOldestMessage () |
Get oldest message. | |
Private Member Functions | |
string | receive () |
Receive a string from the server. | |
Private Attributes | |
bool | state |
Socket state. | |
int | mySock |
Socket handle. | |
string | queue |
Buffer that stores messages. |
This class manage the connection with the irc server. It uses a socket for communication
Definition at line 53 of file socket.h.
Socket::Socket | ( | ) |
Socket::~Socket | ( | ) |
bool Socket::closeSock | ( | ) |
Close the socket.
Close the socket
Definition at line 96 of file socket.cpp.
Referenced by receive(), BotKernel::reconnect(), BotKernel::run(), and ~Socket().
bool Socket::connectSock | ( | int | port, | |
string | serverName, | |||
string | dedicatedIP | |||
) |
Connect the socket to the server.
Connect the socket to a server The socket can be "block type" and use a dedicated IP adress
port | Server port | |
serverName | Server IP or hostname | |
dedicatedIP | Dedicated IP used for connextion. Empty if not used |
Definition at line 57 of file socket.cpp.
Referenced by bashfr(), BotKernel::connect(), planet(), tele(), trad(), and wiki().
string Socket::getOldestMessage | ( | ) |
Get oldest message.
Check queue to get the oldest message. If no message is available, receive() method is called. Then try again to get oldest message. If there is still no message availabe, an empty string is returned.
Definition at line 123 of file socket.cpp.
References queue, and receive().
Referenced by bashfr(), planet(), BotKernel::run(), tele(), trad(), and wiki().
bool Socket::getState | ( | ) |
Get connection state.
Get connection state
Definition at line 111 of file socket.cpp.
References state.
Referenced by BotKernel::run().
string Socket::receive | ( | ) | [private] |
Receive a string from the server.
Receive a string from the server
Definition at line 145 of file socket.cpp.
References closeSock(), mySock, and state.
Referenced by getOldestMessage().
bool Socket::sendStr | ( | string | strData | ) |
Send a string to the server.
Send a string to the server
strData | String to send |
Definition at line 179 of file socket.cpp.
References mySock.
Referenced by bashfr(), planet(), BotKernel::send(), tele(), trad(), and wiki().
int Socket::mySock [private] |
Socket handle.
Definition at line 76 of file socket.h.
Referenced by closeSock(), connectSock(), receive(), sendStr(), and Socket().
string Socket::queue [private] |
Buffer that stores messages.
Definition at line 78 of file socket.h.
Referenced by getOldestMessage(), and Socket().
bool Socket::state [private] |
Socket state.
Definition at line 74 of file socket.h.
Referenced by closeSock(), connectSock(), getState(), receive(), and Socket().