Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Godot game

The Godot add-on announces a game to Funlink hubs such as RustyFunPlayer. It is plain GDScript for Godot 4.2 or later: copy it in, add one node, and hubs offer the player a one-click Connect to the services your game runs, such as an OFS WebSocket or a Buttplug server.

1. Add the add-on

Download funlink-godot-0.1.0.zip from the release and unpack it so that addons/funlink/ sits next to project.godot. Enabling it under Project Settings > Plugins is optional.

2. Announce

Add a FunlinkPeer node to a scene that lives as long as the game, or create one in an autoload:

extends Node

var funlink := FunlinkPeer.new()

func _ready() -> void:
	funlink.app_id = "my-game"
	funlink.app_name = "My Game"
	funlink.app_version = "1.0.0"
	funlink.icon = preload("res://icon.svg")
	funlink.services = [{"protocol": "ofs-ws", "endpoint": "ws://127.0.0.1:8080/ofs"}]
	add_child(funlink)

The node announces when it enters the tree and every 5 seconds after, also while the game is paused. It says bye when it leaves the tree or the window closes.

When a service starts or stops, change services and call funlink.update().

3. Show the hub’s answer

funlink.hubs_changed.connect(func(hubs: Array) -> void:
	var names := hubs.filter(func(hub): return hub.state == "connected").map(func(hub): return hub.hub.name)
	$Status.text = "Connected to " + ", ".join(names) if names else "")

Each entry has hub (id, name, maybe version), supported, state and address.

4. Optional: the local network

For a game on a Steam Deck or a standalone headset that should reach RustyFunPlayer on a PC, set funlink.lan = true before adding the node, and let your services listen on all interfaces instead of 127.0.0.1. lan_hosts also sends the announce to fixed addresses, such as a hub on another subnet. See Local network for what changes.

Exports

  • Android: enable the INTERNET permission in the export preset.
  • Web: browsers cannot open these sockets; start() returns ERR_UNAVAILABLE.
  • Godot .NET: you may use the C# library instead, which also finds hubs.

License

The add-on is under the LGPL-3.0-or-later with a linking exception, so a game can ship it inside its export without providing the means to relink it. Changes to the add-on itself stay under the LGPL.