Installation
Package Information
- Version: 0.1.0
- License: MIT OR Apache-2.0
- Repository: github:moq-dev/moq
- Dependencies:
@moq/lite, WebTransport polyfill for Node.js
Overview
The clock example demonstrates:- Publishing time updates over MoQ
- Subscribing to time updates
- Clock synchronization patterns
- Using MoQ in Node.js applications
CLI Usage
Publishing the Clock
Publish the current time to a broadcast:--url- WebTransport URL of the MoQ relay--broadcast- Name of the broadcast (default: “clock”)--interval- Update interval in milliseconds (default: 1000)--token- JWT authentication token (if required)
Subscribing to the Clock
Subscribe to time updates:--url- WebTransport URL of the MoQ relay--broadcast- Name of the broadcast (default: “clock”)--token- JWT authentication token (if required)
Programmatic Usage
Publishing Time
Subscribing to Time
Clock Synchronization
The example demonstrates a simple clock synchronization pattern:Advanced Synchronization
For more accurate synchronization, implement NTP-like algorithms:Use Cases
The clock example demonstrates patterns useful for:- Distributed systems: Synchronize time across services
- Live events: Coordinate timing for multiple viewers
- Multiplayer games: Synchronize game state timestamps
- Media playback: Align playback across devices
- IoT devices: Coordinate sensor readings
Complete Example
Here’s a complete Node.js application:Node.js Setup
For Node.js applications, install the WebTransport polyfill:Next Steps
@moq/lite
Learn the core protocol used by the clock
@moq/token
Add authentication to your clock
Examples
View the source code
Node.js Guide
Set up Node.js for MoQ