Hey everyone,
It seems that session vars can’t be sent through authentication. I dived in and found a fix that imply modifying Nakama godot module. Here are some notable points :
1. Documentation about session vars in Godot is invalid
var vars = {
"device_os" = OS.get_name,
"device_model" = OS.get_model_name,
"invite_user_id" = "<some_user_id>,
# ...
}
var session : NakamaSession = yield(client.authenticate_device_async("<device_id>", null, true, vars), "completed")
This is not how we declare a dictionnary in Godot. I did the following
var vars = {
"somekey" : "somevalue",
}
var session : NakamaSession = yield(client.authenticate_device_async("<device_id>", null, true, vars), "completed")
2. Nakama serializer does not handles dictionnary in NakamaSerializer.gd
TYPE_DICTIONARY: # Maps
var dict = {}
if content == TYPE_OBJECT: # Map of objects
for l in val:
if val_type != TYPE_OBJECT:
continue
dict[l] = serialize(val)
else: # Map of simple types
for l in val:
dict[l] = val[l]
if val_type != content:
continue
dict[l] = val
It seems that the dict defined here is never added to the “out” variable that is returned. Which basically mean that the dict var is declared but never used. It also seems that “val_type” is never equal to “content”.
To be 100% honest, i’m not totally sure to understand how the whole serializer works, but what I know is that it remove the “vars” defined in the authenticate function and nothing is sent.
I did a quick and dirty fix, but this might not be the real solution to that :
TYPE_DICTIONARY: # Maps
var dict = {}
if content == TYPE_OBJECT: # Map of objects
for l in val:
if val_type != TYPE_OBJECT:
continue
dict[l] = serialize(val)
else: # Map of simple types
for l in val:
dict[l] = val[l]
out[k] = dict
But maybe my problem comes from the vars definition. Is it supposed to be a dictionnary ?
Thanks in advance for your help ;).