POE::C...Bayeux(3pm)

πŸ“¦
version 0.04 Β· 2 versions
, in fedora 43

πŸ’– 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) β€” either 0 or 1, 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 β€” the POE::Session object returned from an internal create() 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 🌈

  • POE
  • POE::Component::Server::Bayeux
  • POE::Component::Client::HTTP

go read your siblings, they're all iconic in their own way 🫢


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