Home  Contents

websocket:new

Websocket Core4 Lua Event System

SYNOPSIS

  1. wsh = websocket:new()
  2. websocket:close()

DESCRIPTION

The function websocket:new() can be used to derive a custom class or to allocate a websocket processing instance that handles the WebSockets protocol.

Deriving a custom class, for example:

MyWebSocket = websocket:new() function MyWebSocket:eventMessage(opcode, msg) print("MESSAGE", opcode, msg:quoted()) end

Using an instance of a derived class, for example:

wsh = MyWebSocket:new() wsh:attachClient(app, socket, body)

The function :close() deactivates an instance. After calling close the handle detaches from its socket (if any) and releases all memory. A closed instance cannot be used again. To be able to reuse an instance later, use websocket:detach().

RETURN VALUE

Returns a new websocket object. The object can be used as a derivative class or as an instance.

SEE ALSO