| 1234567891011121314151617181920212223242526272829303132333435363738394041 | 
if mg.lua_type ~= "websocket" then  mg.write("HTTP/1.0 403 Forbidden\r\n")  mg.write("Connection: close\r\n")  mg.write("\r\n")  mg.write("forbidden")  returnend-- table of all active connectionallConnections = {}-- function to get a client identification stringfunction who(tab)  local ri = allConnections[tab.client].request_info  return ri.remote_addr .. ":" .. ri.remote_portend-- Callback to accept or reject a connectionfunction open(tab)  allConnections[tab.client] = tab  return true -- return true to accept the connectionend-- Callback for "Websocket ready"function ready(tab)  return true -- return true to keep the connection openend-- Callback for "Websocket received data"function data(tab)    mg.write(1, tab.data);    return true -- return true to keep the connection openend-- Callback for "Websocket is closing"function close(tab)    allConnections[tab.client] = nilend
 |