@martini-kit/transport-local
v0.2.0
Published
Local in-memory transport for testing and demos. Part of martini-kit: Multiplayer without networking.
Maintainers
Readme
@martini-kit/transport-local
Multiplayer without networking.
Local transport for martini-kit that enables testing and development of multiplayer games without any network infrastructure.
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
npm install @martini-kit/transport-local @martini-kit/coreQuick Start
import { defineGame, GameRuntime } from '@martini-kit/core';
import { LocalTransport } from '@martini-kit/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); // 1License
Apache-2.0 © Blueprint Lab
