cohtml::ISocketListener

The ISocketListener represents cohtml::View side of the web sockets.

#include <Socket.h>

Public Functions

Name
ISocketListener()
virtual~ISocketListener()
virtual voidOnMessage(const char * bytes, unsigned length)
Called when platform socket receive message new message.
virtual voidOnMessage(const char * bytes, unsigned length, websocket::OpCode opCode)
Called when platform socket receive message new message.
virtual voidOnClose(unsigned code, const char * reason, unsigned length)
Called when platform socket want to close connection.
virtual voidOnError(const char * message, unsigned length)
Called when any error occurred.
virtual voidOnOpen()
Called by platform socket to notify page about successfully connecction establishment.

Public Functions Documentation

function ISocketListener

ISocketListener()

function ~ISocketListener

virtual ~ISocketListener()

function OnMessage

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

Called when platform socket receive message new message.

Parameters:

  • bytes the binary or text data which is send to the page
  • length the length in bytes of the data

Warning: Will be deprecated. Use ISocketListener::OnMessage/3 instead.

function OnMessage

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

Called when platform socket receive message new message.

Parameters:

  • bytes the binary or text data which is send to the page
  • length the length in bytes of the data
  • opCode binary or text opcode of the provided WebSocket message data

function OnClose

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

Called when platform socket want to close connection.

Parameters:

  • code indicates 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 data

function OnError

inline virtual void OnError(
    const char * message,
    unsigned length
)

Called when any error occurred.

Parameters:

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

function OnOpen

inline virtual void OnOpen()

Called by platform socket to notify page about successfully connecction establishment.