# NAME Mercury - Main broker application class # VERSION version 0.003 # DESCRIPTION This is the main broker application class. With this class, you can add a message broker inside your [Mojolicious](https://metacpan.org/pod/Mojolicious) application. It is not necessary to use Mojolicious in order to use Mercury. For how to use Mercury to broker messages for any application, see [the main Mercury documentation](https://metacpan.org/pod/mercury). For how to start the broker application, see [the mercury broker command documentation](https://metacpan.org/pod/Mercury::Command::broker) or run `mercury help broker`. # ROUTES ## /bus/\*topic Establish a WebSocket message bus to send/recieve messages on the given `topic`. All clients connected to the topic will receive all messages published on the topic. This is a shorter way of doing both `/pub/*topic` and `/sub/*topic`, without the hierarchal message passing. ## /sub/\*topic Establish a WebSocket to subscribe to the given `topic`. Messages published to the topic or any child topics will be sent to this subscriber. ## /pub/\*topic Establish a WebSocket to publish to the given `topic`. Messages published to the topic will be sent to all subscribers to the topic or any parent topics. # METHODS ## add\_bus\_peer $c->add_bus_peer( $topic ) Add the current connection as a peer on the given bus topic. Connections can be joined to only one topic. ## remove\_bus\_peer Remove the current connection from the given bus topic. Must be called to clean up the state. ## send\_bus\_message $c->send_bus_message( $topic, $message ) Send a message to all the peers on the given bus. Will not send to the current peer (they should know what they sent). ## add\_topic\_subscriber $c->add_topic_subscriber( $topic ); Add the current connection as a subscriber to the given topic. Connections can be subscribed to only one topic, but they will receive all messages to child topics as well. ## remove\_topic\_subscriber $c->remote_topic_subscriber( $topic ); Remove the current connection from the given topic. Must be called to clean up the state. ## publish\_topic\_message $c->publish_topic_message( $topic, $message ); Publish a message on the given topic. The message will be sent once to any subscriber of this topic or any child topics. # AUTHOR Doug Bell # COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Doug Bell. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.