|
@@ -68,12 +68,6 @@ local function acceptKey(key)
|
|
|
return crypto.toBase64(crypto.hash("sha1", key .. guid))
|
|
|
end
|
|
|
|
|
|
-local function callback(socket)
|
|
|
- function socket.onmessage(payload, opcode)
|
|
|
- socket.send(payload..'!', 1)
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
return function (connection, payload)
|
|
|
local buffer = false
|
|
|
local socket = {}
|
|
@@ -110,6 +104,18 @@ return function (connection, payload)
|
|
|
end
|
|
|
end)
|
|
|
|
|
|
+ connection:on("sent", function(_, _)
|
|
|
+ if socket.onsent ~= nil then
|
|
|
+ socket.onsent()
|
|
|
+ end
|
|
|
+ end)
|
|
|
+
|
|
|
+ connection:on("disconnection", function(_, _)
|
|
|
+ if socket.onclose ~= nil then
|
|
|
+ socket.onclose()
|
|
|
+ end
|
|
|
+ end)
|
|
|
+
|
|
|
local req = dofile("httpserver-request.lc")(payload)
|
|
|
local key = payload:match("Sec%-WebSocket%-Key: ([A-Za-z0-9+/=]+)")
|
|
|
local fileExists = file.open(req.uri.file, "r")
|