NAME

Hypersonic::WebSocket::Room - XS Broadcast support for WebSocket connections

SYNOPSIS

use Hypersonic::WebSocket::Room;
use XS::JIT::Builder;
use XS::JIT;

my $builder = XS::JIT::Builder->new;
Hypersonic::WebSocket::Room->generate_c_code($builder, {
    max_rooms => 1000,
    max_clients_per_room => 10000,
});

# Compile XS functions
XS::JIT->compile(
    code      => $builder->code,
    name      => 'Hypersonic::WebSocket::Room',
    functions => Hypersonic::WebSocket::Room->get_xs_functions,
);

# Now use from Perl - object-oriented API
my $room = Hypersonic::WebSocket::Room->new('chat');
$room->join($fd);
$room->broadcast('Hello!');
$room->leave($fd);
$room->destroy;

DESCRIPTION

Generates XS functions for WebSocket room/channel management via XS::JIT::Builder. All hot paths (membership tracking, broadcast) are in C.

Room objects are blessed scalars containing the room_id, created entirely in XS.

INSTANCE METHODS (XS)

new($name) - Create room, returns blessed room object
destroy() - Destroy room
join($fd) - Add client to room
leave($fd) - Remove client from room
has($fd) - Check if client in room
broadcast($message, [$exclude_fd]) - Send text to all
broadcast_binary($data, [$exclude_fd]) - Send binary to all
count() - Number of clients
count_open() - Open clients (cleans up closed)
close_all([$code], [$reason]) - Close all clients
name() - Get room name
clear($room_id) - Remove all clients without closing