OxiGDAL WebSocket
Advanced real-time WebSocket communication for OxiGDAL with comprehensive broadcasting, pub/sub, and live updates.
Features
WebSocket Server (~1,500 LOC)
- Tokio-tungstenite based WebSocket server
- Connection Management: Track and manage thousands of concurrent connections
- Heartbeat/Ping-Pong: Automatic connection health monitoring
- Connection Pooling: Efficient resource management and reuse
Protocol (~1,000 LOC)
- Binary Protocol: Optimized geospatial binary encoding
- JSON Protocol: Standard JSON for compatibility
- Message Framing: Efficient message packaging and parsing
- Compression: Zstd and gzip compression support
Broadcasting (~800 LOC)
- Pub/Sub Channels: Topic-based message distribution
- Room Management: Group-based communication
- Selective Broadcasting: Filter-based message routing
- Message Filters: Geographic, attribute, and custom filtering
Live Updates (~800 LOC)
- Tile Updates: Real-time map tile notifications
- Feature Updates: GeoJSON feature change tracking
- Change Streams: MongoDB-style change stream processing
- Incremental Updates: Delta-based updates for bandwidth efficiency
Client SDK (~600 LOC)
- JavaScript Client: Browser and Node.js compatible
- TypeScript Definitions: Full type safety
- Reconnection Logic: Automatic reconnection with exponential backoff
- Client-Side Caching: Tile and feature caching
Installation
Add to your Cargo.toml:
[]
= { = true }
Usage
Starting a Server
use Server;
async
Broadcasting Messages
use BroadcastSystem;
use Message;
let system = new;
// Subscribe to topic
let subscriber_id = new_v4;
system.subscribe.await?;
// Publish message
let message = ping;
system.publish.await?;
Tile Updates
use ;
let manager = new;
let coord = new;
let data = vec!;
let update = full;
manager.add_update?;
JavaScript Client
const client = ;
client.;
client.;
client.;
Architecture
Server Components
- Connection: WebSocket connection wrapper with state management
- HeartbeatMonitor: Monitors connection health with ping/pong
- ConnectionManager: Manages all active connections
- ConnectionPool: Pools idle connections for reuse
- Server: Main server orchestrator
Protocol Components
- ProtocolCodec: Encoding/decoding messages
- FrameCodec: Message framing
- CompressionCodec: Data compression
- BinaryCodec: Geospatial binary protocol
- JsonCodec: JSON protocol
Broadcasting Components
- TopicChannel: Pub/sub topic implementation
- RoomManager: Group chat room management
- MessageRouter: Message routing and distribution
- MessageFilter: Filtering rules for selective broadcasting
Update Components
- TileUpdateManager: Manages tile update notifications
- FeatureUpdateManager: Tracks feature changes
- ChangeStream: MongoDB-style change streams
- IncrementalUpdateManager: Delta-based updates
COOLJAPAN Compliance
✅ Pure Rust: 100% Rust implementation ✅ No unwrap(): All errors handled properly ✅ Files < 2000 lines: All source files under 2000 LOC ✅ Workspace deps: Uses workspace dependencies ✅ No warnings: Compiles without warnings
Statistics
- Total LOC: ~5,300
- Test Coverage: Comprehensive unit and integration tests
- Documentation: Full API documentation with examples
License
Apache-2.0
Author
COOLJAPAN OU (Team Kitasan)