Schema definition for the WebSocket Plugin, which provides WebSocket connection handling and real-time communication support.
Property | Value |
---|---|
Schema URL | https://rustybeam.net/schema/WebSocketPlugin |
Parent Schema | https://rustybeam.net/schema/HandlerPlugin |
Description | WebSocket connection handling and real-time communication |
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. |
<tr itemscope itemtype="https://rustybeam.net/schema/WebSocketPlugin">
<span itemprop="library">file://./plugins/librusty_beam_websocket.so</span>
</tr>
<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>
// 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);
};
This schema inherits from the HandlerPlugin schema, which provides:
config_file
- Configuration file pathrulesfile
- Rules file pathAnd ultimately from the base Plugin schema, which provides:
library
- Plugin library pathplugin
- Base plugin reference propertymax_connections
should be a reasonable limit (e.g., 1-10000)ping_interval
should be between 10-300 seconds when implementedmessage_size_limit
should be reasonable for your use case (e.g., 1KB-10MB)broadcast_buffer_size
should accommodate expected message volumeThe WebSocket Plugin is designed for future extensibility: