POE::C...Bayeux(3pm)
π POE::Component::Client::Bayeux β bestie, it's a Bayeux/cometd client in POE π
okay so this is a page from the User Contributed Perl Documentation, and it's all about POE::Component::Client::Bayeux β Bayeux/cometd client implementation in POE. pull up a chair, we're doing cometd today π
β¨ SYNOPSIS β¨
like, here's the whole vibe in one go:
use POE qw(Component::Client::Bayeux);
POE::Component::Client::Bayeux->spawn(
Host => '127.0.0.1',
Alias => 'comet',
);
POE::Session->create(
inline_states => {
_start => sub {
my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->alias_set('my_client');
$kernel->post('comet', 'init');
$kernel->post('comet', 'subscribe', '/chat/demo', 'events');
$kernel->post('comet', 'publish', '/chat/demo', {
user => "POE",
chat => "POE has joined",
join => JSON::XS::true,
});
},
events => sub {
my ($kernel, $heap, $message) = @_[KERNEL, HEAP, ARG0];
print STDERR "Client got subscribed message:\n" . Dumper($message);
},
},
);
$poe_kernel->run();
spawn it, alias it, init it, subscribe it, publish it, run it. that's the whole girlboss pipeline π
πΈ DESCRIPTION πΈ
so this module implements the Bayeux Protocol (1.0draft1) from the Dojo Foundation. it's also called cometd, and honestly bestie, Bayeux is a low-latency routing protocol for JSON encoded events between clients and servers, in a publish-subscribe model. lowkey iconic β¨
this here is the client implementation. it is not feature complete, but it works at the moment for testing a Bayeux server. she's giving "works on my machine, and that machine is a test server" energy and we respect that π«Ά
π¦ USAGE π¦
spawn (...)
Create a new Bayeux client. Arguments to this method:
Host(required) β connect to this host.Port(default: 80) β connect to this port.SSL(default: 0) β use SSL on connection.Alias(default:'bayeux_client') β the POE session alias for local sessions to interact with.Debug(default: 0) β either0or1, indicates level of logging.LogFile(default: undef) β logfile to write output to.LogStdout(default: 1) β if false, no logger output to STDOUT.CrossDomain(not implemented) β enables cross domain protocol of messaging. yeah bestie she's not implemented, don't come for her πErrorCallback(default: none) β provide a coderef that will receive a message hashref of any failed messages (errors in protocol, or simply unhandled messages).
Returns a class object with methods of interest:
sessionβ thePOE::Sessionobject returned from an internalcreate()call. that's your girl right there π
π POE STATES π
the following are states you can post to to interact with the client. so like, this is how you talk to her:
init ()
Initializes the client, connecting to the server, and sets up long polling. the opening move, the main character entrance, the "hi bestie I've arrived" π
publish ($channel, $message)
Publishes arbitrary message to the channel given. Message will have 'clientId' and 'id' fields auto-populated. so don't you dare fill those in yourself, she's got it π
subscribe ($channel, $callback)
Subscribes client to the channel given. Callback can either be a coderef or the name of a state in the calling session. Callback will get one arg, the message that was posted to the channel subscribed to. one arg, that's it, that's the whole gift π
unsubscribe ($channel)
Unsubscribes from channel. it's giving "we're not friends anymore" but, like, politely π
disconnect ()
Sends a disconnect request. bye babes π¦
reconnect ()
Disconnect and reconnect. she said "actually, never mind, I'm back" π₯
β TODO β
Lots of stuff.
The code currently implements only the long-polling transport and doesn't yet strictly follow all the directives in the protocol document http://svn.xantus.org/shortbus/trunk/bayeux/bayeux.html
ngl bestie, "Lots of stuff." is the most honest TODO list in the entire CPAN and I am obsessed with her for it π
π KNOWN BUGS π
No known bugs, but I'm sure you can find some.
okay the way this is a challenge. she's daring you. periodt π
π SEE ALSO π
POEPOE::Component::Server::BayeuxPOE::Component::Client::HTTP
go read your siblings, they're all iconic in their own way π«Ά
π COPYRIGHT π
Copyright (c) 2008 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
π AUTHOR π
Eric Waters <ewaters@uarc.com>
okay bestie that's the whole page π
she's documented by User Contributed Perl Documentation, she's running on perl v5.42.0, and this version is dated 2025-07-25 β so go forth, spawn your client, subscribe to /chat/demo, and slay β¨π¦πΈ
π¦ where this page comes from
- fedora 43: perl-POE-Component-Server-Bayeux 0.04-43.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms