#include <remotecontrol.h>
Public Member Functions | |
RemoteControl (BotKernel *) | |
Constructor. | |
~RemoteControl () | |
Destructor. | |
void | setSocketList (struct timeval *, fd_set *) |
Prepare FD for select and return highest sock. | |
int | manageNewConnection (int) |
manage incomming connections | |
void * | tcpServer (BotKernel *) |
TCP server to receive connections. | |
Private Attributes | |
CPPThread * | pt |
Thread object. | |
int | sockfd |
Socket used to accept connections. | |
int * | clients |
Array to store connections. | |
unsigned int | MYPORT |
Port used for connection. | |
unsigned int | MAXCLIENTS |
Maximum clients that will be able to connect. | |
Static Private Attributes | |
static const int | BACKLOG = 5 |
Listen backlog. | |
static const int | MAXDATASIZE = 100 |
Max data size fo communication. |
This plugins make the bot listen on a port. A client can connect to the bot with a telnet command and can then control the bot by sending commands
Definition at line 46 of file remotecontrol.h.
RemoteControl::RemoteControl | ( | BotKernel * | b | ) |
Constructor.
Constructor
Definition at line 36 of file remotecontrol.cpp.
References Plugin::author, Plugin::bindFunction(), clients, Plugin::description, CPPThread::exec(), BotKernel::getCONFF(), Plugin::getName(), ConfigurationFile::getValue(), IN_FIRST_WORD, MAXCLIENTS, MYPORT, myThread(), Plugin::name, pt, Tools::strToUnsignedInt(), Plugin::version, and WARNING.
RemoteControl::~RemoteControl | ( | ) |
Destructor.
Destructor
Definition at line 57 of file remotecontrol.cpp.
References clients, MAXCLIENTS, pt, and sockfd.
int RemoteControl::manageNewConnection | ( | int | sock | ) |
manage incomming connections
Manage new connections. If there is enough room connection will be stored, else, connexion have to be closed
sock | Incomming client socket |
Definition at line 181 of file remotecontrol.cpp.
References clients, and MAXCLIENTS.
Referenced by tcpServer().
void RemoteControl::setSocketList | ( | struct timeval * | tv, | |
fd_set * | readfds | |||
) |
Prepare FD for select and return highest sock.
Construct a socket list to be used by select. Sockets are added to fd list
tv | timeval structure | |
readfds | fd_set will store sockets |
Definition at line 162 of file remotecontrol.cpp.
References clients, MAXCLIENTS, and sockfd.
Referenced by tcpServer().
void * RemoteControl::tcpServer | ( | BotKernel * | b | ) |
TCP server to receive connections.
TCP server to receive connections. This function will wait for a connection and talk to the kernel to execute command requested by the user connected
b | Pointer on the kernel |
Definition at line 77 of file remotecontrol.cpp.
References BACKLOG, clients, ERROR, BotKernel::getSysLog(), INFO, Tools::intToStr(), LogFile::log(), manageNewConnection(), MAXCLIENTS, MAXDATASIZE, MYPORT, setSocketList(), sockfd, and WARNING.
Referenced by myThread().
const int RemoteControl::BACKLOG = 5 [static, private] |
int* RemoteControl::clients [private] |
Array to store connections.
Definition at line 54 of file remotecontrol.h.
Referenced by manageNewConnection(), RemoteControl(), setSocketList(), tcpServer(), and ~RemoteControl().
unsigned int RemoteControl::MAXCLIENTS [private] |
Maximum clients that will be able to connect.
Definition at line 58 of file remotecontrol.h.
Referenced by manageNewConnection(), RemoteControl(), setSocketList(), tcpServer(), and ~RemoteControl().
const int RemoteControl::MAXDATASIZE = 100 [static, private] |
Max data size fo communication.
Definition at line 62 of file remotecontrol.h.
Referenced by tcpServer().
unsigned int RemoteControl::MYPORT [private] |
Port used for connection.
Definition at line 56 of file remotecontrol.h.
Referenced by RemoteControl(), and tcpServer().
CPPThread* RemoteControl::pt [private] |
Thread object.
Definition at line 50 of file remotecontrol.h.
Referenced by RemoteControl(), and ~RemoteControl().
int RemoteControl::sockfd [private] |
Socket used to accept connections.
Definition at line 52 of file remotecontrol.h.
Referenced by setSocketList(), tcpServer(), and ~RemoteControl().