NAME
ChatApp::WebSocket - WebSocket chat handler using PAGI::WebSocket
DESCRIPTION
This module handles WebSocket connections for real-time chat using the PAGI::WebSocket convenience wrapper. Compare with the original at examples/10-chat-showcase/lib/ChatApp/WebSocket.pm to see how PAGI::WebSocket simplifies the code.
Key Improvements
No manual protocol handling -
$ws->acceptreplaces waiting for websocket.connect and sending websocket.acceptClean disconnect handling -
$ws->on_closecallback runs on any disconnect, no need to handle websocket.disconnect in the message loopJSON methods -
$ws->send_jsonand$ws->each_jsonhandle encoding/decoding automaticallytry_send_json - Safe send that returns false on closed connection instead of throwing
SEE ALSO
PAGI::WebSocket, "10-chat-showcase/lib/ChatApp/WebSocket.pm" in examples