feat add spdlog
Some checks failed
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Failing after 29s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Failing after 16s
sm-rpc / build (Debug, host.gcc) (push) Failing after 11s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Failing after 12s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Failing after 11s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Failing after 11s
sm-rpc / build (Release, host.gcc) (push) Failing after 12s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Failing after 16s

This commit is contained in:
tqcq
2025-08-22 18:22:57 +08:00
parent 3d395b45f0
commit c68893bace
2331 changed files with 1306786 additions and 103 deletions

View File

@@ -0,0 +1,41 @@
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")
return
end
-- table of all active connection
allConnections = {}
-- function to get a client identification string
function who(tab)
local ri = allConnections[tab.client].request_info
return ri.remote_addr .. ":" .. ri.remote_port
end
-- Callback to accept or reject a connection
function open(tab)
allConnections[tab.client] = tab
return true -- return true to accept the connection
end
-- Callback for "Websocket ready"
function ready(tab)
return true -- return true to keep the connection open
end
-- Callback for "Websocket received data"
function data(tab)
mg.write(1, tab.data);
return true -- return true to keep the connection open
end
-- Callback for "Websocket is closing"
function close(tab)
allConnections[tab.client] = nil
end