]> git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/test/echo.lua
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / test / echo.lua
1
2 if mg.lua_type ~= "websocket" then
3 mg.write("HTTP/1.0 403 Forbidden\r\n")
4 mg.write("Connection: close\r\n")
5 mg.write("\r\n")
6 mg.write("forbidden")
7 return
8 end
9
10
11 -- table of all active connection
12 allConnections = {}
13
14 -- function to get a client identification string
15 function who(tab)
16 local ri = allConnections[tab.client].request_info
17 return ri.remote_addr .. ":" .. ri.remote_port
18 end
19
20 -- Callback to accept or reject a connection
21 function open(tab)
22 allConnections[tab.client] = tab
23 return true -- return true to accept the connection
24 end
25
26 -- Callback for "Websocket ready"
27 function ready(tab)
28 return true -- return true to keep the connection open
29 end
30
31 -- Callback for "Websocket received data"
32 function data(tab)
33 mg.write(1, tab.data);
34 return true -- return true to keep the connection open
35 end
36
37 -- Callback for "Websocket is closing"
38 function close(tab)
39 allConnections[tab.client] = nil
40 end
41