WebSocket
Prism has built-in WebSocket support with no external dependencies. It handles the HTTP upgrade handshake, frame parsing, and provides an actor-based connection model for safe concurrent messaging.How It Works
- Client sends an HTTP request with
Upgrade: websocket - Prism validates the handshake and sends a
101 Switching Protocolsresponse - The connection switches to the WebSocket protocol
- Your handler receives connect, message, and disconnect events
Creating a Handler
Implement thePrismWebSocketHandler protocol:
Echo Handler
Registering WebSocket Routes
Register Handler
Building a Chat Server
Simple Chat Server
Client-Side Connection
Browser Client
Message Types
- Text
- Binary
Real-Time Notifications Example
Notification System