Gamend - Godot Integration

banner

Gamend now has a module that connects to Godot so it’s possible to write server side logic in GDScript.

  +--------------------+
  | GameServer/Gamend  |
  +--------------------+
            |
            | calls hooks (WebSocket)
            | 
            v
  +--------------------+
  | godot_hook plugin  |
  | (spawns Godot)     |
  | ( WS client)       |
  +--------------------+
            |
            | sends and receives hooks through Websocket Client
            v
  +--------------------+
  | Godot headless     |
  | (starts WS server) |
  +--------------------+

The godot_hook is available in the gamend_starter repo. The Dockerfile downloads Godot, and then the godot_hook starts it and forwards hook events.

class_name GamendServerTest
extends GamendServer

# Callbacks
func _after_user_login(user: Dictionary):
	print("after_user_login: ", user)

func _after_startup():
	print("after_startup")

# RPC
func new_func(arg: String):
	print("new_func: ", arg)
	return arg + "abc"

Callbacks are forwarded from the server, and you can also expose new functions that the user can then call from client side. There is also a new admin SDK so everything that is possible from Elixir is also possible from Godot (autogenerated with OpenAPI).

Eg.

var gamend_api: GamendApi

func _init():

func _ready():
  gamend_api = GamendApi.new("localhost", 4000, false)
	add_child(gamend_api)
  _get_kv()

func _get_kv():
	var result = await gamend_api.kv_get_kv("my_data")
	if result.error:
		print("Cannot get KV at my_data")
		return Dictionary()
	print("KV is: ", result.response.data.data)