Closed britzl closed 2 years ago
Hi @britzl,
Thanks for the changes you've made so far, removing the intermediate message body creation step will hugely improve the developer experience. We have a couple more requests that will help bring the Defold SDK in line with our other SDKs.
Please move client functions to the Client object rather than have them on the Nakama object.
Instead of:
local client = nakama.create_client(...)
local result = nakama.add_friends(client, ...)
It should be:
local client = nakama.create_client(...)
local result = client.add_friends(...)
Similar to above, socket functions and events should live on the Socket object.
Instead of:
nakama.on_matchpresence(socket, fn)
It should be:
socket.on_match_presence(fn)
For reference you can take a look at the IClient
and ISocket
definitions in the .NET SDK.
https://github.com/heroiclabs/nakama-dotnet/blob/master/Nakama/IClient.cs
https://github.com/heroiclabs/nakama-dotnet/blob/master/Nakama/ISocket.cs
Please let me know if you have any questions or issues.
I've updated the API to follow the recommendations from @tomglenn while remaining true to Lua.
Previously:
local client = nakama.create_client(config)
local email = "super@heroes.com"
local password = "batsignal"
local session = nakama.authenticate_email(client, email, password)
pprint(session)
You now have two options:
local client = nakama.create_client(config)
local email = "super@heroes.com"
local password = "batsignal"
-- same as before
local session = nakama.authenticate_email(client, email, password)
-- new
local session = client:authenticate_email(email, password)
pprint(session)
I've done the same for sockets (and moved the socket code to a separate socket.lua which is generated from the real-time protobuf message definitions):
local client = nakama.create_client(config)
local socket = client:create_socket()
socket:on_match_presence_event(callback)
socket:send_status_update("my status")
I need to do a whole lot of tests before this PR is ready for review, but it's moving the right direction at least!
Update:
socket:send_status_update("my status")
-> socket.send_status_update("my status")
@tomglenn could you resolve conversations that are addressed.
@britzl @tomglenn how are we tracking a version change? With the major changes we should bump a major version.
@britzl @tomglenn how are we tracking a version change? With the major changes we should bump a major version.
Agreed. @britzl can you also update the CHANGELOG
to reflect the changes.
Agreed. @britzl can you also update the
CHANGELOG
to reflect the changes.
Done. I've retroactively added previous releases to the CHANGELOG.
This PR updated the API design to expand the message body arguments in the API functions.
Previously:
New: