Cocos2d-x  v3.10
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
WebSocket::Delegate Class Referenceabstract

The delegate class is used to process websocket events. More...

Public Member Functions

virtual ~Delegate ()
 Destructor of Delegate. More...
 
var ~Delegate ()
 Destructor of Delegate. More...
 
virtual void onOpen (WebSocket *ws)=0
 This function to be called after the client connection complete a handshake with the remote server. More...
 
virtual void onMessage (WebSocket *ws, const Data &data)=0
 This function to be called when data has appeared from the server for the client connection. More...
 
virtual void onClose (WebSocket *ws)=0
 When the WebSocket object connected wants to close or the protocol won't get used at all and current _readyState is State::CLOSING,this function is to be called. More...
 
virtual void onError (WebSocket *ws, const ErrorCode &error)=0
 This function is to be called in the following cases: More...
 

Detailed Description

The delegate class is used to process websocket events.

The most member function are pure virtual functions,they should be implemented the in subclass.

Constructor & Destructor Documentation

virtual ~Delegate ( )
inlinevirtual

Destructor of Delegate.

var ~Delegate ( )
inlinevirtual

Destructor of Delegate.

Member Function Documentation

virtual void onOpen ( WebSocket ws)
pure virtual

This function to be called after the client connection complete a handshake with the remote server.

This means that the WebSocket connection is ready to send and receive data. The WebSocket object connected.

var onOpen ( var  ws)
pure virtual

This function to be called after the client connection complete a handshake with the remote server.

This means that the WebSocket connection is ready to send and receive data. The WebSocket object connected.

virtual void onMessage ( WebSocket ws,
const Data data 
)
pure virtual

This function to be called when data has appeared from the server for the client connection.

The WebSocket object connected. Data object for message.

var onMessage ( var  ws,
var  data 
)
pure virtual

This function to be called when data has appeared from the server for the client connection.

The WebSocket object connected. Data object for message.

virtual void onClose ( WebSocket ws)
pure virtual

When the WebSocket object connected wants to close or the protocol won't get used at all and current _readyState is State::CLOSING,this function is to be called.

The WebSocket object connected.

var onClose ( var  ws)
pure virtual

When the WebSocket object connected wants to close or the protocol won't get used at all and current _readyState is State::CLOSING,this function is to be called.

The WebSocket object connected.

virtual void onError ( WebSocket ws,
const ErrorCode error 
)
pure virtual

This function is to be called in the following cases:

  1. client connection is failed.
  2. the request client connection has been unable to complete a handshake with the remote server.
  3. the protocol won't get used at all after this callback and current _readyState is State::CONNECTING.
  4. when a socket descriptor needs to be removed from an external polling array. in is again the struct libwebsocket_pollargs containing the fd member to be removed. If you are using the internal polling loop, you can just ignore it and current _readyState is State::CONNECTING. The WebSocket object connected. WebSocket::ErrorCode enum,would be ErrorCode::TIME_OUT or ErrorCode::CONNECTION_FAILURE.
var onError ( var  ws,
var  error 
)
pure virtual

This function is to be called in the following cases:

  1. client connection is failed.
  2. the request client connection has been unable to complete a handshake with the remote server.
  3. the protocol won't get used at all after this callback and current _readyState is State::CONNECTING.
  4. when a socket descriptor needs to be removed from an external polling array. in is again the struct libwebsocket_pollargs containing the fd member to be removed. If you are using the internal polling loop, you can just ignore it and current _readyState is State::CONNECTING. The WebSocket object connected. WebSocket::ErrorCode enum,would be ErrorCode::TIME_OUT or ErrorCode::CONNECTION_FAILURE.

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