open-index/open-npm huggingface dataset:
npm package: @playertwo/transport-local
Description: Local in-memory transport for testing and demos. Part of playertwo: Multiplayer without networking.
Author: Yao
Latest version: 0.2.0

# @playertwo/transport-local

**Multiplayer without networking.**

Local transport for playertwo that enables testing and development of multiplayer games without any network infrastructure.

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/BlueprintLabIO/playertwo/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/v/@playertwo/transport-local)](https://www.npmjs.com/package/@playertwo/transport-local)

## Features

- **Zero network setup** - Test multiplayer games instantly
- **Multiple instances** - Run multiple game instances in same process/page
- **Perfect for development** - Fast iteration without server setup
- **Perfect for demos** - Show multiplayer features without deployment
- **Deterministic** - Predictable behavior for testing

## Installation

```bash
npm install @playertwo/transport-local @playertwo/core
```

## Quick Start

```typescript
import { defineGame, GameRuntime } from '@playertwo/core';
import { LocalTransport } from '@playertwo/transport-local';

const game = defineGame({
  initialState: { count: 0 },
  actions: {
    increment: (state) => { state.count++; }
  }
});

// Create two local instances
const transport1 = new LocalTransport({ roomId: 'test-room' });
const transport2 = new LocalTransport({ roomId: 'test-room' });

const runtime1 = new GameRuntime(game, transport1, { isHost: true });
const runtime2 = new GameRuntime(game, transport2, { isHost: false });

// Connect them
await transport1.connect();
await transport2.connect();

// Dispatch action from host
runtime1.dispatchAction('increment', {});

// Both runtimes see the change!
console.log(runtime1.state.count); // 1
console.log(runtime2.state.count); // 1
```

## License

Apache-2.0 © Blueprint Lab

## Links

- [GitHub Repository](https://github.com/BlueprintLabIO/playertwo)
- [Report Issues](https://github.com/BlueprintLabIO/playertwo/issues)
- [NPM Package](https://www.npmjs.com/package/@playertwo/transport-local)