websocket
Full-duplex WebSocket client and server. Connect to WebSocket endpoints, send text or binary frames, and build real-time server applications.
Install
ppm install websocket
Usage Example
uses websocket;
// Client: connect and send
var ws := Connect('wss://echo.example.com');
Send(ws, 'Hello from PascalAI!');
// Handle incoming messages
ws.OnMessage := function(const Msg: TWSMessage): string begin
WriteLn('Received: ' + Msg.Data);
Result := '';
end;
// Server mode
Listen(8080, procedure begin
WriteLn('Client connected');
end);
Close(ws);
Features
Full-duplex WebSocket (RFC 6455)
Text and binary frame support
Server mode with Listen()
Async OnMessage and OnClose handlers
Auto-reconnect on disconnect