cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
WebSocket::Delegate Class Referenceabstract

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

#include <WebSocket.h>

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...
 
var onMessage ( var ws, var data)
 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...
 
var onClose ( var ws)
 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 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.

Parameters
wsThe 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.

Parameters
wsThe 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.
Parameters
wsThe WebSocket object connected.
errorWebSocket::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.
Parameters
wsThe WebSocket object connected.
errorWebSocket::ErrorCode enum,would be ErrorCode::TIME_OUT or ErrorCode::CONNECTION_FAILURE.
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.

Parameters
wsThe WebSocket object connected.
dataData 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.

Parameters
wsThe WebSocket object connected.
dataData object for message.
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.

Parameters
wsThe 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.

Parameters
wsThe WebSocket object connected

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