WebSocketPlugin Schema

Schema definition for the WebSocket Plugin, which provides WebSocket connection handling and real-time communication support.

Schema Information

Property Value
Schema URL https://rustybeam.net/schema/WebSocketPlugin
Parent Schema https://rustybeam.net/schema/HandlerPlugin
Description WebSocket connection handling and real-time communication

Properties

Property Type Cardinality Description
max_connections https://rustybeam.net/schema/Number 0..1 Maximum number of concurrent WebSocket connections. Default is unlimited. Future configuration option.
ping_interval https://rustybeam.net/schema/Number 0..1 Interval in seconds for sending WebSocket ping frames to keep connections alive. Future configuration option.
message_size_limit https://rustybeam.net/schema/Number 0..1 Maximum WebSocket message size in bytes. Future configuration option for preventing oversized messages.
broadcast_buffer_size https://rustybeam.net/schema/Number 0..1 Size of the broadcast channel buffer for message distribution. Future configuration option.
Current Implementation
The WebSocket Plugin currently uses default values for all configuration options. The properties listed above are planned future enhancements that will provide fine-grained control over WebSocket behavior.

Usage Examples

Basic WebSocket Support

<tr itemscope itemtype="https://rustybeam.net/schema/WebSocketPlugin">
    <span itemprop="library">file://./plugins/librusty_beam_websocket.so</span>
</tr>

Future Configuration (When Implemented)

<tr itemscope itemtype="https://rustybeam.net/schema/WebSocketPlugin">
    <span itemprop="library">file://./plugins/librusty_beam_websocket.so</span>
    <span itemprop="max_connections">100</span>
    <span itemprop="ping_interval">30</span>
    <span itemprop="message_size_limit">65536</span>
    <span itemprop="broadcast_buffer_size">1000</span>
</tr>

WebSocket Features

Client-Side Usage

JavaScript WebSocket Connection

// Connect to WebSocket endpoint
const ws = new WebSocket('ws://localhost:3000/chat');

// Handle connection open
ws.onopen = function(event) {
    console.log('WebSocket connected');
    ws.send(JSON.stringify({
        type: 'join',
        username: 'user123'
    }));
};

// Handle incoming messages
ws.onmessage = function(event) {
    const message = JSON.parse(event.data);
    console.log('Received:', message);
};

// Send messages
function sendMessage(text) {
    ws.send(JSON.stringify({
        type: 'message',
        content: text,
        timestamp: Date.now()
    }));
}

// Handle connection close
ws.onclose = function(event) {
    console.log('WebSocket disconnected:', event.code, event.reason);
};

Schema Inheritance

This schema inherits from the HandlerPlugin schema, which provides:

And ultimately from the base Plugin schema, which provides:

WebSocket Protocol Support

Validation Rules

Plugin Pipeline Placement
The WebSocket Plugin should be placed after authentication and authorization plugins but before the File Handler Plugin. This ensures WebSocket connections are properly authenticated and authorized.

Use Cases

Integration with Other Plugins

Future Enhancements

The WebSocket Plugin is designed for future extensibility:

See Also