cohtml::IClientSideSocket

The IClientSideSocket represents platform/client specific part of the web sockets.

#include <Socket.h>

Public Functions

Name
IClientSideSocket()
virtual~IClientSideSocket()
virtual voidSend(const char * bytes, unsigned length)
Called when the JS web socket want to send text data to the server.
virtual voidSend(const char * bytes, unsigned length, cohtml::websocket::OpCode opCode)
Called when the JS web socket want to send binary or text data to the server.
virtual unsignedGetBufferedAmount()
Called when the JS web socket want to get buffered amount of data.
virtual const char *GetProtocol()
Called when the JS web socket want to name of the sub-protocol the server selected.
virtual voidClose(unsigned code, const char * reason, unsigned length)
Called when the JS web socket want to close the connection with server.
virtual voidTerminate(unsigned code, const char * reason, unsigned length)
Called when the JS web socket will no longer will call IClientSideSocket and now is safe to destroy this object. The method must close the connection to the server and also it’s no longer safe to use a.

Public Functions Documentation

function IClientSideSocket

IClientSideSocket()

function ~IClientSideSocket

virtual ~IClientSideSocket()

function Send

inline virtual void Send(
    const char * bytes,
    unsigned length
)

Called when the JS web socket want to send text data to the server.

Parameters:

  • bytes text data which is send to the server
  • length the length in bytes of the data

Warning: Will be deprecated, implement IClientSideSocket::Send/3 instead.

function Send

inline virtual void Send(
    const char * bytes,
    unsigned length,
    cohtml::websocket::OpCode opCode
)

Called when the JS web socket want to send binary or text data to the server.

Parameters:

  • bytes the binary or text data which is send to the server
  • length the length in bytes of the data
  • opCode desired opcode of a WebSocket message to be sent

function GetBufferedAmount

inline virtual unsigned GetBufferedAmount()

Called when the JS web socket want to get buffered amount of data.

Return: the number of bytes of data that have been queued using calls to IClientSideSocket::Send()

function GetProtocol

inline virtual const char * GetProtocol()

Called when the JS web socket want to name of the sub-protocol the server selected.

Return: selected sub-protocol

function Close

inline virtual void Close(
    unsigned code,
    const char * reason,
    unsigned length
)

Called when the JS web socket want to close the connection with server.

Parameters:

  • code indicate the status code explaining why the connection is being closed
  • reason a human-readable string explaining why the connection is closing
  • length the length in bytes of the reason

function Terminate

inline virtual void Terminate(
    unsigned code,
    const char * reason,
    unsigned length
)

Called when the JS web socket will no longer will call IClientSideSocket and now is safe to destroy this object. The method must close the connection to the server and also it’s no longer safe to use a.

Parameters:

  • code indicate the status code explaining why the connection is being closed
  • reason a human-readable string explaining why the connection is closing
  • length the length in bytes of the reason