Copy the addon into your project:
# Clone or download into your project
git clone https://github.com/widgrensit/asobi-godot.git
cp -r asobi-godot/addons/asobi your_project/addons/asobiThen enable the plugin: Project → Project Settings → Plugins → Asobi.
Add an AsobiClient node to your scene and configure it:
# asobi_client is an autoload or node in your scene
@onready var asobi: AsobiClient = $AsobiClient
# Configure in the inspector or via code:
# host: "localhost"
# port: 8080
# use_ssl: false# Register
var resp = await asobi.auth.register("player1", "secret123", "Player One")
# Login
var resp = await asobi.auth.login("player1", "secret123")
# Session token is stored automatically
print("Logged in as: ", asobi.player_id)Connect via WebSocket and listen for events using signals:
# Connect signals
asobi.realtime.connected.connect(_on_connected)
asobi.realtime.match_state.connect(_on_match_state)
asobi.realtime.matchmaker_matched.connect(_on_matched)
# Connect to server
asobi.realtime.connect_to_server()
func _on_connected():
print("Connected!")
func _on_match_state(payload: Dictionary):
# Update game state from server
pass
func _on_matched(payload: Dictionary):
var match_id = payload["match_id"]
asobi.realtime.join_match(match_id)# Queue via WebSocket (recommended)
asobi.realtime.add_to_matchmaker("arena")
# Or via REST
var ticket = await asobi.matchmaker.add("arena")
var status = await asobi.matchmaker.status(ticket["ticket_id"])Send player input to the server-authoritative game loop:
# Send input (fire-and-forget)
asobi.realtime.send_match_input({"action": "move", "x": 1, "y": 0})
# Send shooting input
asobi.realtime.send_match_input({
"action": "fire",
"aim_x": mouse_pos.x,
"aim_y": mouse_pos.y
})# Submit a score
await asobi.leaderboards.submit_score("weekly", 1500)
# Get top scores
var top = await asobi.leaderboards.get_top("weekly", 10)
# Get scores around current player
var around = await asobi.leaderboards.get_around_self("weekly")# Listen for messages
asobi.realtime.chat_message.connect(_on_chat)
# Join a channel and send a message
asobi.realtime.join_chat("lobby")
asobi.realtime.send_chat_message("lobby", "Hello!")
func _on_chat(payload: Dictionary):
print(payload["content"])