RemoteControl Class Reference

Plugin that allow remote TCP control. More...

#include <remotecontrol.h>

Inheritance diagram for RemoteControl:

Plugin

List of all members.

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

CPPThreadpt
 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.


Detailed Description

Plugin that allow remote TCP control.

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.


Constructor & Destructor Documentation

RemoteControl::RemoteControl ( BotKernel b  ) 

RemoteControl::~RemoteControl (  ) 

Destructor.

Destructor

Definition at line 57 of file remotecontrol.cpp.

References clients, MAXCLIENTS, pt, and sockfd.


Member Function Documentation

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

Parameters:
sock Incomming client socket
Returns:
Client slot (-1 if no room)

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

Parameters:
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

Parameters:
b Pointer on the kernel
Precondition:
This function must be called in a threaded function to don't block the bot
Returns:
NOTHING. Juste a NULL pointer

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().


Member Data Documentation

const int RemoteControl::BACKLOG = 5 [static, private]

Listen backlog.

Definition at line 60 of file remotecontrol.h.

Referenced by tcpServer().

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().

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().


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

Generated on Sun Aug 16 15:28:56 2009 for trustyRC by  doxygen 1.5.8