mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
edit: change name for better comprehansion
This commit is contained in:
parent
209edbf8a6
commit
061af311b1
|
@ -13,7 +13,7 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
||||||
LastFrame = CurTime() + 0.25
|
LastFrame = CurTime() + 0.25
|
||||||
|
|
||||||
// Capture frame
|
// Capture frame
|
||||||
local captureData = {
|
local captureConfig = {
|
||||||
format = "jpeg",
|
format = "jpeg",
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
|
@ -22,7 +22,7 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
||||||
quality = 50,
|
quality = 50,
|
||||||
}
|
}
|
||||||
|
|
||||||
local screenCapture = render.Capture(captureData)
|
local screenCapture = render.Capture(captureConfig)
|
||||||
screenCapture = util.Base64Encode(screenCapture)
|
screenCapture = util.Base64Encode(screenCapture)
|
||||||
|
|
||||||
local size = math.Round(string.len(screenCapture) / 1024)
|
local size = math.Round(string.len(screenCapture) / 1024)
|
||||||
|
@ -31,8 +31,8 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
||||||
gmInte.http.post("/streams/frames",
|
gmInte.http.post("/streams/frames",
|
||||||
{
|
{
|
||||||
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
["player"] = gmInte.getPlayerFormat(LocalPlayer()),
|
||||||
["screenshot"] = screenCapture,
|
["base64Capture"] = screenCapture,
|
||||||
["captureData"] = captureData,
|
["captureConfig"] = captureConfig,
|
||||||
["size"] = size .. "KB"
|
["size"] = size .. "KB"
|
||||||
},
|
},
|
||||||
function(code, body)
|
function(code, body)
|
||||||
|
@ -42,6 +42,7 @@ hook.Add("PostRender", "gmInte:PostRender:Stream:Frame", function()
|
||||||
gmInte.log("Failed to send frame to WebPanel", true)
|
gmInte.log("Failed to send frame to WebPanel", true)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
StreamsRequeted = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -51,10 +52,7 @@ end)
|
||||||
function gmInte.takeScreenShot(serverID, authToken)
|
function gmInte.takeScreenShot(serverID, authToken)
|
||||||
gmInte.config.id = serverID
|
gmInte.config.id = serverID
|
||||||
gmInte.config.token = authToken
|
gmInte.config.token = authToken
|
||||||
|
StreamsRequeted = true
|
||||||
timer.Simple(0.2, function()
|
|
||||||
StreamsRequeted = true
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.stopScreenShot()
|
function gmInte.stopScreenShot()
|
||||||
|
@ -66,11 +64,14 @@ end
|
||||||
//
|
//
|
||||||
|
|
||||||
concommand.Add("gmod_integration_stream", function()
|
concommand.Add("gmod_integration_stream", function()
|
||||||
if (StreamsRequeted) then
|
StreamsRequeted = !StreamsRequeted
|
||||||
gmInte.stopScreenShot()
|
gmInte.log("Streaming frames to WebPanel: " .. tostring(StreamsRequeted))
|
||||||
gmInte.log("Stopped streaming frames to WebPanel")
|
|
||||||
else
|
-- if (StreamsRequeted) then
|
||||||
gmInte.SendNet("getSingleUseToken")
|
-- gmInte.stopScreenShot()
|
||||||
gmInte.log("Started streaming frames to WebPanel")
|
-- gmInte.log("Stopped streaming frames to WebPanel")
|
||||||
end
|
-- else
|
||||||
|
-- gmInte.SendNet("getSingleUseToken")
|
||||||
|
-- gmInte.log("Started streaming frames to WebPanel")
|
||||||
|
-- end
|
||||||
end)
|
end)
|
Loading…
Reference in New Issue
Block a user