NAME

Multi-User Chat Showcase - PAGI Demo Application

SYNOPSIS

perl -Ilib -Iexamples/10-chat-showcase/lib bin/pagi-server \
    --app examples/10-chat-showcase/app.pl --port 5000

DESCRIPTION

A comprehensive demonstration of PAGI's capabilities through a multi-user chat application featuring:

  • WebSocket - Real-time bidirectional chat messaging

  • HTTP - Static file serving and REST API endpoints

  • SSE - Server-Sent Events for system notifications

  • Lifespan - Application lifecycle management

ENDPOINTS

HTTP

GET /

Serves the chat frontend (index.html)

GET /api/rooms

Lists all chat rooms with user counts

GET /api/room/:name/history

Gets message history for a room

GET /api/stats

Server statistics (uptime, users, messages)

WebSocket

/ws/chat

WebSocket endpoint for chat. Connect with ?name=Username query parameter.

SSE

/events

Server-Sent Events stream for system notifications

FEATURES

Chat Features

  • Multiple chat rooms (create, join, leave)

  • Real-time message broadcasting

  • Typing indicators

  • Private messaging (/pm user message)

  • User presence tracking

  • Message history (last 100 per room)

Commands

Type these in chat:

/help           - Show available commands
/rooms          - List all rooms
/users          - List users in current room
/join <room>    - Join or create a room
/leave          - Leave current room
/pm <user> <msg> - Send private message
/nick <name>    - Change your nickname
/me <action>    - Send action message

AUTHOR

PAGI Demo Application