heroiclabs / nakama-defold

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

Creating a Match in Defold #17

Closed MrZak-dev closed 3 years ago

MrZak-dev commented 3 years ago

I couldn't find Lua reference to create a Match (not a matchmaker) , i used the javascript api as refence . To Create Match in js you have to use

var response = await socket.createMatch();
console.log("Created match with ID:", response.match.match_id);

You can share the match id with other players to join . i want to do the same thing using Defold and Lua . if i am not mistaken , the same should be in Lua :

local match_create_message = {
        match_create = {} -- empty , no arguments       
}

local match_result = nakama.socket_send(socket, match_create_message,callback)

This caused the server to disconnect with :

{"level":"warn","ts":"2021-01-04T11:23:32.727Z","msg":"Received malformed payload","uid":"51fc50d1-da4e-4f4c-b74a-ea60e75bad37","sid":"71335a58-9d9d-4d72-8cd4-3942df576269","data":"eyJjaWQiOiIxIiwibWF0Y2hfY3JlYXRlIjpbXX0="}

after decoding the data

{"cid":"1","match_create":[]}

Note : A list with supported messages / arguments by nakama.socket_send() will be very helpful in these cases , the official documentation only covers creating a channel_join massage type example .