cocos2d-x  3.3
 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>

Inheritance diagram for Console:
Ref

Classes

struct  Command
 

Public Member Functions

 Console ()
 Constructor. More...
 
virtual ~Console ()
 Destructor. More...
 
bool listenOnTCP (int port)
 starts listening to specifed TCP port More...
 
bool listenOnFileDescriptor (int fd)
 starts listening to specifed file descriptor More...
 
void stop ()
 stops the Console. More...
 
void addCommand (const Command &cmd)
 add custom command More...
 
void log (const char *buf)
 log something in the console More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 NA NA More...
 

Protected Member Functions

void loop ()
 
ssize_t readline (int fd, char *buf, size_t maxlen)
 
ssize_t readBytes (int fd, char *buffer, size_t maxlen, bool *more)
 
bool parseCommand (int fd)
 
void addClient ()
 
void commandHelp (int fd, const std::string &args)
 
void commandExit (int fd, const std::string &args)
 
void commandSceneGraph (int fd, const std::string &args)
 
void commandFileUtils (int fd, const std::string &args)
 
void commandConfig (int fd, const std::string &args)
 
void commandTextures (int fd, const std::string &args)
 
void commandResolution (int fd, const std::string &args)
 
void commandProjection (int fd, const std::string &args)
 
void commandDirector (int fd, const std::string &args)
 
void commandTouch (int fd, const std::string &args)
 
void commandUpload (int fd)
 
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 

Protected Attributes

int _listenfd
 
int _maxfd
 
std::vector< int > _fds
 
std::thread _thread
 
fd_set _read_set
 
bool _running
 
bool _endThread
 
std::string _writablePath
 
std::map< std::string, Command_commands
 
bool _sendDebugStrings
 
std::mutex _DebugStringsMutex
 
std::vector< std::string > _DebugStrings
 
intptr_t _touchId
 
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

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.

Member Function Documentation

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

add custom command

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

starts listening to specifed file descriptor

bool listenOnTCP ( int  port)

starts listening to specifed TCP port

void log ( const char *  buf)

log something in the console

void loop ( )
protected
bool parseCommand ( int  fd)
protected
ssize_t readBytes ( int  fd,
char *  buffer,
size_t  maxlen,
bool *  more 
)
protected
ssize_t readline ( int  fd,
char *  buf,
size_t  maxlen 
)
protected
void stop ( )

stops the Console.

'stop' will be called at destruction time as well

Member Data Documentation

std::map<std::string, Command> _commands
protected
std::vector<std::string> _DebugStrings
protected
std::mutex _DebugStringsMutex
protected
bool _endThread
protected
std::vector<int> _fds
protected
int _listenfd
protected
int _maxfd
protected
fd_set _read_set
protected
bool _running
protected
bool _sendDebugStrings
protected
std::thread _thread
protected
intptr_t _touchId
protected
std::string _writablePath
protected

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