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

#include <WebSocket.h>

Inheritance diagram for WebSocket:
LuaWebSocket

Classes

struct  Data
 Data structure for message. More...
 
class  Delegate
 The delegate class to process websocket events. More...
 

Public Types

enum  ErrorCode { TIME_OUT, CONNECTION_FAILURE, UNKNOWN }
 Errors in websocket. More...
 
enum  State { CONNECTING, OPEN, CLOSING, CLOSED }
 Websocket state. More...
 

Public Member Functions

 WebSocket ()
virtual ~WebSocket ()
bool init (const Delegate &delegate, const std::string &url, const std::vector< std::string > *protocols=nullptr)
 The initialized method for websocket. More...
 
void send (const std::string &message)
 Sends string data to websocket server. More...
 
void send (const unsigned char *binaryMsg, unsigned int len)
 Sends binary data to websocket server. More...
 
void close ()
 Closes the connection to server. More...
 
State getReadyState ()
 Gets current state of connection. More...
 

Friends

class WebSocketCallbackWrapper
class WsThreadHelper

Member Enumeration Documentation

enum ErrorCode
strong

Errors in websocket.

Enumerator
TIME_OUT 
CONNECTION_FAILURE 
UNKNOWN 
var ErrorCode
strong

Errors in websocket.

Enumerator
TIME_OUT 
CONNECTION_FAILURE 
UNKNOWN 
local ErrorCode
strong

Errors in websocket.

Enumerator
TIME_OUT 
CONNECTION_FAILURE 
UNKNOWN 
enum State
strong

Websocket state.

Enumerator
CONNECTING 
OPEN 
CLOSING 
CLOSED 
var State
strong

Websocket state.

Enumerator
CONNECTING 
OPEN 
CLOSING 
CLOSED 
local State
strong

Websocket state.

Enumerator
CONNECTING 
OPEN 
CLOSING 
CLOSED 

Constructor & Destructor Documentation

WebSocket ( )
var ctor ( )
local WebSocket ( )
virtual ~WebSocket ( )
virtual

Member Function Documentation

void close ( )

Closes the connection to server.

var close ( )

Closes the connection to server.

local close ( )

Closes the connection to server.

State getReadyState ( )

Gets current state of connection.

var getReadyState ( )

Gets current state of connection.

local getReadyState ( )

Gets current state of connection.

bool init ( const Delegate delegate,
const std::string &  url,
const std::vector< std::string > *  protocols = nullptr 
)

The initialized method for websocket.

    It needs to be invoked right after websocket instance is allocated.
Parameters
delegateThe delegate which want to receive event from websocket.
urlThe URL of websocket server.
Returns
true: Success, false: Failure
var init ( var  delegate,
var  url,
var  protocols = nullptr 
)

The initialized method for websocket.

    It needs to be invoked right after websocket instance is allocated.
Parameters
delegateThe delegate which want to receive event from websocket.
urlThe URL of websocket server.
Returns
true: Success, false: Failure
local init ( local  delegate,
local  url,
local  protocols = nullptr 
)

The initialized method for websocket.

    It needs to be invoked right after websocket instance is allocated.
Parameters
delegateThe delegate which want to receive event from websocket.
urlThe URL of websocket server.
Returns
true: Success, false: Failure
void send ( const std::string &  message)

Sends string data to websocket server.

var send ( var  message)

Sends string data to websocket server.

local send ( local  message)

Sends string data to websocket server.

void send ( const unsigned char *  binaryMsg,
unsigned int  len 
)

Sends binary data to websocket server.

var send ( var  binaryMsg,
var  len 
)

Sends binary data to websocket server.

local send ( local  binaryMsg,
local  len 
)

Sends binary data to websocket server.

Friends And Related Function Documentation

friend class
WebSocketCallbackWrapper
friend
var WebSocketCallbackWrapper
friend
local WebSocketCallbackWrapper
friend
friend class WsThreadHelper
friend
var WsThreadHelper
friend
local WsThreadHelper
friend

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