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->accept replaces waiting for websocket.connect and sending websocket.accept

  • Clean disconnect handling - $ws->on_close callback runs on any disconnect, no need to handle websocket.disconnect in the message loop

  • JSON methods - $ws->send_json and $ws->each_json handle encoding/decoding automatically

  • try_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