Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
WebSocket Class Reference

Public Member Functions

 WebSocket (HttpServerConnection *conn)
 Object class constructor. More...
 
virtual ~WebSocket ()
 Virtual object class destructor. More...
 
virtual void send (const char *message, int length, wsFrameType type=WS_TEXT_FRAME)
 Send data to other peer. More...
 
void sendString (const String &message)
 Send a string to other peer. More...
 
void sendBinary (const uint8_t *data, int size)
 Send binary data to other peer. More...
 
void enableCommand ()
 Enable command processing. More...
 
void close ()
 Close webSocket connection. More...
 
void setTimeOut (uint16_t waitTimeOut)
 Set TCP connection timeout. More...
 
bool operator== (const WebSocket &other) const
 Test if two sockets are the same. More...
 
void setUserData (void *userData)
 Store user data pointer for this socket(connection) More...
 
void * getUserData ()
 Get user data pointer for this socket(connection) More...
 

Protected Member Functions

bool initialize (HttpRequest &request, HttpResponse &response)
 
bool is (HttpServerConnection *conn)
 

Friends

class HttpServer
 

Constructor & Destructor Documentation

WebSocket::WebSocket ( HttpServerConnection conn)

Object class constructor.

Parameters
connPointer to HttpServer connection object that this webSocket will use
virtual WebSocket::~WebSocket ( )
virtual

Virtual object class destructor.

Member Function Documentation

void WebSocket::close ( )

Close webSocket connection.

void WebSocket::enableCommand ( )

Enable command processing.

void* WebSocket::getUserData ( )

Get user data pointer for this socket(connection)

Returns
Pointer to user defined data
bool WebSocket::operator== ( const WebSocket other) const
inline

Test if two sockets are the same.

Parameters
otherThe other webSocket
Returns
true if the two webSockets are defining the same connection
virtual void WebSocket::send ( const char *  message,
int  length,
wsFrameType  type = WS_TEXT_FRAME 
)
virtual

Send data to other peer.

Parameters
messagePointer to buffer to send
lengthLength of buffer to send
typeFrametype of the message to be sent. Default is text frame.
void WebSocket::sendBinary ( const uint8_t *  data,
int  size 
)

Send binary data to other peer.

Parameters
dataPointer to buffer to send
sizeLength of buffer to send
void WebSocket::sendString ( const String message)

Send a string to other peer.

Parameters
messageString object holding the message to send
void WebSocket::setTimeOut ( uint16_t  waitTimeOut)
inline

Set TCP connection timeout.

Parameters
waitTimeOutTCP timeout
void WebSocket::setUserData ( void *  userData)

Store user data pointer for this socket(connection)

Parameters
userDataPointer to user defined data