Skip to content

Repository files navigation

Relay

R ●●● lay

Multiplayer DSL for Modern Games

License: MIT Status: Beta npm version


⚠️ WARNING: BETA SOFTWARE

Relay is currently in active development and is intended for developer beta testing only.

  • 🚧 Unstable - APIs and features may change without notice
  • 🐛 Bugs Expected - Code may contain errors or unexpected behavior
  • 🧪 Not Production Ready - Use with caution in real projects
  • 📝 Feedback Welcome - Please report issues and suggestions

Use at your own risk. We recommend thorough testing before any production use.


What is Relay?

Relay is a Domain-Specific Language (DSL) and toolchain that simplifies multiplayer game development. Write your game logic in Relay's intuitive syntax, and the compiler generates production-ready server code, client SDKs, and networking protocols.

The Problem

Building multiplayer games traditionally requires:

  • Deep networking expertise (WebSockets, UDP, TCP)
  • Complex state synchronization logic
  • Client-side prediction and reconciliation
  • Extensive boilerplate code

Relay abstracts all of this away.

How It Works

1. Write game logic in Relay DSL (.relay files)
   → Define entities, actions, and events
   
2. Compile with Relay CLI
   → Generates server code (TypeScript/Node.js)
   → Generates client SDKs (TypeScript, Unity C#, Godot GDScript)
   
3. Integrate generated code
   → Drop into your game engine
   → Multiplayer works out-of-the-box

Quick Start

Installation

npm install -g @relay/cli

Create a Project

relay init my-game
cd my-game

Write Game Logic

game MyGame {
  config {
    maxPlayers: 2
    turnBased: true
  }

  entity Player {
    id: string
    score: int = 0
  }

  action addScore(player: Player, points: int) {
    validate {
      points > 0
    }

    execute {
      player.score += points
    }

    sync {
      to_all reliable
    }
  }
}

Build & Run

# Check syntax
relay check src/game.relay

# Start dev server with hot reload
relay dev src/game.relay

# Build for production
relay build src/game.relay --target typescript

Features

🎯 Type-Safe DSL

  • Strongly typed syntax prevents runtime errors
  • IntelliSense support in VS Code
  • Compile-time validation catches bugs early

🎮 Engine Agnostic

  • TypeScript/JavaScript - Web games
  • Unity C# - Desktop and mobile
  • Godot GDScript - Cross-platform

🔒 Security Built-In

  • Server-authoritative by default
  • Automatic input validation
  • Configurable rate limiting

⚡ Developer Experience

  • Hot reload during development
  • Clear, actionable error messages
  • Visual debugging tools
  • Extensive documentation

Project Structure

relay/
├── packages/
│   ├── cli/              # Command-line interface
│   ├── compiler/         # DSL compiler
│   ├── runtime/          # WebSocket game server
│   └── client-sdk/       # Client libraries
├── examples/
│   └── tic-tac-toe/      # Example game
├── vscode-extension/     # VS Code support
└── docs/                 # Documentation

CLI Commands

Command Description
relay init <name> Create new project
relay check <file> Validate syntax and types
relay build <file> Compile to production code
relay dev <file> Start dev server with hot reload
relay --help Show help

DSL Syntax Overview

Entities

entity Player {
  id: string
  position: Vector2 = (0, 0)
  health: int range(0, 100) = 100
  
  computed isAlive: bool => health > 0
}

Actions

action move(player: Player, direction: Vector2) {
  validate {
    player.isAlive
    direction.magnitude <= 1.0
  }

  execute {
    player.position += direction * 5.0
  }

  sync {
    to_all unreliable
    predict client
  }
}

Events

event playerDeath(player: Player, killer: Player?) {
  sync {
    to_all reliable
    animation "death"
  }
}

Lifecycle Hooks

onPlayerJoin(player: Player) {
  // Initialize new player
}

onTick(deltaTime: float) {
  // Game loop
}

VS Code Extension

Install the Relay VS Code extension for:

  • ✅ Syntax highlighting
  • ✅ Code snippets
  • ✅ IntelliSense (coming soon)
  • ✅ Error diagnostics (coming soon)

Examples

Tic-Tac-Toe

Simple turn-based game demonstrating core concepts.

cd examples/tic-tac-toe
relay dev game.relay

Contributing

Contributions are welcome! Please read our Contributing Guide first.

# Clone the repo
git clone https://github.com/relay-dsl/relay.git

# Install dependencies
npm install

# Build all packages
npm run build

# Run tests
npm test

License

MIT License - see LICENSE for details.


Links


Made with ❤️ by Buchori Muslim

About

Multiplayer DSL for Modern Games - Beta

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages