heroiclabs / nakama-defold

Defold client for Nakama server.
https://heroiclabs.com
Apache License 2.0
74 stars 12 forks source link

Missing Party API #30

Closed dlannan-kakutai closed 1 year ago

dlannan-kakutai commented 2 years ago

I think the party API is missing from the interface. https://heroiclabs.com/docs/social-realtime-parties/#join-party

I have tried to manually add it, but Im not sure its working properly (dont know if there needs to be an extra module on the server). I'm running the docker-compose nakama with version 3.3.0 in it. Server is Ubuntu 16.04 - xenial (this may be an issue - will be moving to 20 soon) https://github.com/heroiclabs/nakama

I have tried extending the interfaces like so:

--------------------------------------------------------------------------------
--- Create a match_create socket message
function M.create_party_create_message( open, maxsize )
    local message = {
        party_create = {
            open        = open,
            maxsize     = maxsize,
        }
    }
    return message
end

Im not sure if this is correct, but according to the JS client, it looks right. Id like to use this feature for a very simple way to join people together - seems like an ideal method. I suspect a client side implementation may be required. If so, I'm happy to contribute if you can point me towards some info to do so - I have been looking at the JS code, so this may be the best starting point anyway.

britzl commented 2 years ago

@novabyte I don't see anything about parties in the API definition used when generating the Lua client. How is this supposed to work?

lugehorsam commented 2 years ago

Hey @britzl @dlannan it's a websocket-based interface so there are no OpenAPI definitions for it.

There are some efforts by developers to create Websocket API schemas in general but we haven't adopted any yet.

There is nothing special on the server that needs to be done in terms of modules, etc. You just need to use a Nakama 3.0+ server. Ideally, wait for 3.4.0 to fully test because we are making a couple tweaks. But you'll be able to start now.

I'd recommend simply looking at the .NET and JS clients since they have the same exact APIs and translating it to Lua. But definitely reach out to me if you have any questions.

britzl commented 2 years ago

Thanks. Documenting the API using some kind of schema would be very helpful.

dlannan-kakutai commented 2 years ago

@britzl, would it be possible to "hand roll" a schema file for specific inclusions of interfaces like this? Looking at the JS, I think it should be possible? I'd be happy to knock one out, just not sure how to build the extension to use it :)

britzl commented 2 years ago

We can manually add the required functions, either in nakama.lua or in a separate Lua module.

If added to nakama.lua it should be added to the template file that is used when generating the API: https://github.com/heroiclabs/nakama-defold/tree/master/codegen

dlannan-kakutai commented 2 years ago

Ok. I have figured a few things out. The documents and other API's are different to the lua ones. I have been trying to create party's with open and maxcount params, but there are none. Works fine without:

--------------------------------------------------------------------------------
--- Create a match_create socket message
function M.create_party_create_message( )
    local message = {
        party_create = {
        }
    }
    return message
end

I have also been working on some rpc calls, and that has been frustrating. I'll not document it here. I'll add another Issue. Just so people are aware that the docs and the api's dont really line up well.

I'll create some party commands and submit a PR for it (I'll put them into the codegen).

britzl commented 1 year ago

Realtime party API functions were added a while back: https://github.com/heroiclabs/nakama-defold/blob/master/nakama/socket.lua#L316-L518

Closing.