Hi,
First post here. I have a unique problem and I would like to hear what the best solution would be.
Requirements:
I want to make a simple web game with no authentication and use Nakama for relayed matches using the Godot Client SDK bridge. I don’t want authentication and I want this to be a web game mainly for portfolio and prototyping purposes.
Problem:
Currently in Godot 4, web exports do not support the function OS.get_unique_id(). So when creating the session with device id, I generate my own ids. Basically this creates an account every time. This works but it is flooding the database.
I see this old thread on temporary accounts. Would running a custom script on the database to delete the users be the solution here? How about a background job? I don’t see much documentation on background jobs.
Any help is appreciated. Thanks!
Setup:
Nakama (docker self-host) ver: 3.23.0+1811efb0
CockroachDB latest v23.1
Client SDK: Godot latest (v3.4.0)
Godot 4.3 stable
Cheers,
Carlos
Ok after a day or two of trying different things. I decided with making a nakama runtime module and using the function sqlExec() to run sql code on the cockrachdb. Now I can make a sever to server call with the curl command every day (example here) using a cron job.
Here is that code for anyone that is interested:
let InitModule: nkruntime.InitModule =
function(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, initializer: nkruntime.Initializer)
{
initializer.registerRpc('deleteallusers', rpcDeleteAllUsers);
logger.info("RPC modules Initialized.");
}
function rpcDeleteAllUsers(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: string): string
{
if (ctx.userId)
{
logger.error("RPC was called by a user.");
return "";
}
logger.info("rpcDeleteAllUsers called.");
let query = 'DELETE FROM users';
let result: nkruntime.SqlExecResult;
try
{
nk.sqlExec(query, []);
} catch(error)
{
logger.error("rpcDeleteAllusers: Failed running query.", error);
return JSON.stringify({ success: false });
}
return JSON.stringify({ success: true });
}