Expand description
OxiGDAL WebSocket Streaming
This crate provides WebSocket support for real-time geospatial data streaming.
§Features
- WebSocket Server: Axum-based WebSocket server with connection management
- WebSocket Client: Async client with reconnection support
- Message Protocol: Multiple formats (JSON, MessagePack, Binary) with compression
- Tile Streaming: Real-time map tile delivery with delta encoding
- Feature Streaming: GeoJSON feature updates with change detection
- Event Streaming: System events, progress updates, and notifications
- Subscription Management: Spatial, temporal, and attribute-based filtering
- Backpressure Control: Automatic throttling and flow control
§Examples
§Server
use oxigdal_ws::server::WebSocketServer;
#[tokio::main]
async fn main() -> oxigdal_ws::error::Result<()> {
let server = WebSocketServer::builder()
.bind("0.0.0.0:9001")?
.max_connections(10000)
.build();
server.run().await?;
Ok(())
}§Client
use oxigdal_ws::client::WebSocketClient;
#[tokio::main]
async fn main() -> oxigdal_ws::error::Result<()> {
let mut client = WebSocketClient::connect("ws://localhost:9001/ws").await?;
// Subscribe to tiles
let sub_id = client.subscribe_tiles(
[-122.5, 37.5, -122.0, 38.0],
10..14
).await?;
// Get tile stream
let mut tiles = client.tile_stream();
while let Some(tile) = tiles.next_tile().await {
println!("Received tile: {:?}", tile.coords());
}
Ok(())
}Re-exports§
pub use client::ClientConfig;pub use client::WebSocketClient;pub use error::Error;pub use error::Result;pub use protocol::ChangeType;pub use protocol::Compression;pub use protocol::EventType;pub use protocol::Message;pub use protocol::MessageFormat;pub use protocol::SubscriptionFilter;pub use server::ServerConfig;pub use server::WebSocketServer;pub use stream::BackpressureController;pub use stream::BackpressureState;pub use stream::DeltaEncoder;pub use stream::EventData;pub use stream::EventStream;pub use stream::FeatureData;pub use stream::FeatureStream;pub use stream::MessageStream;pub use stream::TileData;pub use stream::TileStream;pub use subscription::Subscription;pub use subscription::SubscriptionManager;pub use subscription::SubscriptionType;
Modules§
- client
- WebSocket client implementation.
- error
- Error types for WebSocket operations.
- handlers
- WebSocket handlers
- prelude
- Prelude module for convenient imports
- protocol
- WebSocket protocol definitions and message types.
- server
- WebSocket server implementation.
- stream
- Data streaming utilities for WebSocket connections.
- subscription
- Subscription management for WebSocket clients.