Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save c0ldfront/13d180af14c06a4967521703e77a621f to your computer and use it in GitHub Desktop.
Save c0ldfront/13d180af14c06a4967521703e77a621f to your computer and use it in GitHub Desktop.
local nk = require("nakama")
local function f_after_match_maker(context, payload)
-- for key, value in pairs(context) do
-- print(("key %q :: value %q"):format(key, value))
-- end
-- for key, value in pairs(payload) do
-- -- print(("key %q :: value %q"):format(key, value))
-- if(key == "match_join") then
-- for k,v in pairs(value) do
-- print(("k: %q :: v: %q"):format(k,v))
-- end
-- end
-- end
-- nk.logger_info(context.match_id)
local token = GetToken(payload.match_join.token)
local decodedtoken = nk.base64_decode(token)
print(decodedtoken)
end
function GetToken(jwt)
local token
local index = 0
for i in string.gmatch(jwt, "[^%.]+") do
if(index == 1) then
token = i
break
end
index = index + 1
end
return token
end
nk.register_rt_after(f_after_match_maker,"MatchJoin")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment