cocos2d-x  3.0-rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Console Class Reference

Console is helper class that lets the developer control the game from TCP connection. More...

#include <CCConsole.h>

Classes

struct  Command
 

Public Member Functions

 Console ()
 Constructor. More...
 
virtual ~Console ()
 Destructor. More...
 
local ~Console ()
 Destructor. More...
 
bool listenOnTCP (int port)
 starts listening to specifed TCP port More...
 
var listenOnTCP ( var port)
 starts listening to specifed TCP port More...
 
local listenOnTCP ( local port)
 starts listening to specifed TCP port More...
 
bool listenOnFileDescriptor (int fd)
 starts listening to specifed file descriptor More...
 
var listenOnFileDescriptor ( var fd)
 starts listening to specifed file descriptor More...
 
local listenOnFileDescriptor ( local fd)
 starts listening to specifed file descriptor More...
 
void stop ()
 stops the Console. More...
 
var stop ()
 stops the Console. More...
 
local stop ()
 stops the Console. More...
 
void addCommand (const Command &cmd)
 add custom command More...
 
var addCommand ( var cmd)
 add custom command More...
 
local addCommand ( local cmd)
 add custom command More...
 
void log (const char *buf)
 log something in the console More...
 

Protected Member Functions

void loop ()
ssize_t readline (int fd, char *buf, int maxlen)
var readline ( var fd, var buf, var maxlen)
local readline ( local fd, local buf, local maxlen)
ssize_t readfile (int fd, std::string &file_name, int file_size)
local readfile ( local fd, local file_name, local file_size)
bool parseCommand (int fd)
var parseCommand ( var fd)
local parseCommand ( local fd)
void addClient ()
var addClient ()
local addClient ()
void commandHelp (int fd, const std::string &args)
var commandHelp ( var fd, var args)
local commandHelp ( local fd, local args)
void commandExit (int fd, const std::string &args)
var commandExit ( var fd, var args)
local commandExit ( local fd, local args)
void commandSceneGraph (int fd, const std::string &args)
var commandSceneGraph ( var fd, var args)
local commandSceneGraph ( local fd, local args)
void commandFileUtils (int fd, const std::string &args)
var commandFileUtils ( var fd, var args)
local commandFileUtils ( local fd, local args)
void commandConfig (int fd, const std::string &args)
var commandConfig ( var fd, var args)
local commandConfig ( local fd, local args)
void commandTextures (int fd, const std::string &args)
var commandTextures ( var fd, var args)
local commandTextures ( local fd, local args)
void commandResolution (int fd, const std::string &args)
var commandResolution ( var fd, var args)
local commandResolution ( local fd, local args)
void commandProjection (int fd, const std::string &args)
var commandProjection ( var fd, var args)
local commandProjection ( local fd, local args)
void commandDirector (int fd, const std::string &args)
var commandDirector ( var fd, var args)
local commandDirector ( local fd, local args)
void commandTouch (int fd, const std::string &args)
var commandTouch ( var fd, var args)
local commandTouch ( local fd, local args)
void commandUpload (int fd, const std::string &args)
var commandUpload ( var fd, var args)
local commandUpload ( local fd, local args)

Protected Attributes

int _listenfd
int _maxfd
var _maxfd
local _maxfd
std::vector< int > _fds
var _fds
local _fds
std::thread _thread
var _thread
local _thread
fd_set _read_set
var _read_set
local _read_set
bool _running
var _running
local _running
bool _endThread
var _endThread
local _endThread
bool _file_uploading
var _file_uploading
local _file_uploading
ssize_t _upload_file_size
var _upload_file_size
local _upload_file_size
std::string _upload_file_name
var _upload_file_name
local _upload_file_name
std::map< std::string, Command_commands
var _commands
local _commands
bool _sendDebugStrings
var _sendDebugStrings
local _sendDebugStrings
std::mutex _DebugStringsMutex
var _DebugStringsMutex
local _DebugStringsMutex
std::vector< std::string > _DebugStrings
var _DebugStrings
local _DebugStrings
int _touchId
var _touchId
local _touchId

Detailed Description

Console is helper class that lets the developer control the game from TCP connection.

Console will spawn a new thread that will listen to a specified TCP port. Console has a basic token parser. Each token is associated with an std::function<void(int)>. If the std::function<> needs to use the cocos2d API, it needs to call

``` scheduler->performFunctionInCocosThread( ... ); ```

Constructor & Destructor Documentation

Console ( )

Constructor.

virtual ~Console ( )
virtual

Destructor.

var ~Console ( )
virtual

Destructor.

local ~Console ( )
virtual

Destructor.

Member Function Documentation

void addClient ( )
protected
var addClient ( )
protected
local addClient ( )
protected
void addCommand ( const Command cmd)

add custom command

var addCommand ( var  cmd)

add custom command

local addCommand ( local  cmd)

add custom command

void commandConfig ( int  fd,
const std::string &  args 
)
protected
var commandConfig ( var  fd,
var  args 
)
protected
local commandConfig ( local  fd,
local  args 
)
protected
void commandDirector ( int  fd,
const std::string &  args 
)
protected
var commandDirector ( var  fd,
var  args 
)
protected
local commandDirector ( local  fd,
local  args 
)
protected
void commandExit ( int  fd,
const std::string &  args 
)
protected
var commandExit ( var  fd,
var  args 
)
protected
local commandExit ( local  fd,
local  args 
)
protected
void commandFileUtils ( int  fd,
const std::string &  args 
)
protected
var commandFileUtils ( var  fd,
var  args 
)
protected
local commandFileUtils ( local  fd,
local  args 
)
protected
void commandHelp ( int  fd,
const std::string &  args 
)
protected
var commandHelp ( var  fd,
var  args 
)
protected
local commandHelp ( local  fd,
local  args 
)
protected
void commandProjection ( int  fd,
const std::string &  args 
)
protected
var commandProjection ( var  fd,
var  args 
)
protected
local commandProjection ( local  fd,
local  args 
)
protected
void commandResolution ( int  fd,
const std::string &  args 
)
protected
var commandResolution ( var  fd,
var  args 
)
protected
local commandResolution ( local  fd,
local  args 
)
protected
void commandSceneGraph ( int  fd,
const std::string &  args 
)
protected
var commandSceneGraph ( var  fd,
var  args 
)
protected
local commandSceneGraph ( local  fd,
local  args 
)
protected
void commandTextures ( int  fd,
const std::string &  args 
)
protected
var commandTextures ( var  fd,
var  args 
)
protected
local commandTextures ( local  fd,
local  args 
)
protected
void commandTouch ( int  fd,
const std::string &  args 
)
protected
var commandTouch ( var  fd,
var  args 
)
protected
local commandTouch ( local  fd,
local  args 
)
protected
void commandUpload ( int  fd,
const std::string &  args 
)
protected
var commandUpload ( var  fd,
var  args 
)
protected
local commandUpload ( local  fd,
local  args 
)
protected
bool listenOnFileDescriptor ( int  fd)

starts listening to specifed file descriptor

var listenOnFileDescriptor ( var  fd)

starts listening to specifed file descriptor

local listenOnFileDescriptor ( local  fd)

starts listening to specifed file descriptor

bool listenOnTCP ( int  port)

starts listening to specifed TCP port

var listenOnTCP ( var  port)

starts listening to specifed TCP port

local listenOnTCP ( local  port)

starts listening to specifed TCP port

void log ( const char *  buf)

log something in the console

var log ( var  buf)

log something in the console

local log ( local  buf)

log something in the console

void loop ( )
protected
var loop ( )
protected
local loop ( )
protected
bool parseCommand ( int  fd)
protected
var parseCommand ( var  fd)
protected
local parseCommand ( local  fd)
protected
ssize_t readfile ( int  fd,
std::string &  file_name,
int  file_size 
)
protected
var readfile ( var  fd,
var  file_name,
var  file_size 
)
protected
local readfile ( local  fd,
local  file_name,
local  file_size 
)
protected
ssize_t readline ( int  fd,
char *  buf,
int  maxlen 
)
protected
var readline ( var  fd,
var  buf,
var  maxlen 
)
protected
local readline ( local  fd,
local  buf,
local  maxlen 
)
protected
void stop ( )

stops the Console.

'stop' will be called at destruction time as well

var stop ( )

stops the Console.

'stop' will be called at destruction time as well

local stop ( )

stops the Console.

'stop' will be called at destruction time as well

Member Data Documentation

std::map<std::string, Command>
_commands
protected
var _commands
protected
local _commands
protected
std::vector<std::string>
_DebugStrings
protected
var _DebugStrings
protected
local _DebugStrings
protected
std::mutex _DebugStringsMutex
protected
var _DebugStringsMutex
protected
local _DebugStringsMutex
protected
bool _endThread
protected
var _endThread
protected
local _endThread
protected
std::vector<int> _fds
protected
var _fds
protected
local _fds
protected
bool _file_uploading
protected
var _file_uploading
protected
local _file_uploading
protected
int _listenfd
protected
var _listenfd
protected
local _listenfd
protected
int _maxfd
protected
var _maxfd
protected
local _maxfd
protected
fd_set _read_set
protected
var _read_set
protected
local _read_set
protected
bool _running
protected
var _running
protected
local _running
protected
bool _sendDebugStrings
protected
var _sendDebugStrings
protected
local _sendDebugStrings
protected
std::thread _thread
protected
var _thread
protected
local _thread
protected
int _touchId
protected
var _touchId
protected
local _touchId
protected
std::string _upload_file_name
protected
var _upload_file_name
protected
local _upload_file_name
protected
ssize_t _upload_file_size
protected
var _upload_file_size
protected
local _upload_file_size
protected

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