# NAME

Mercury - Main broker application class

# VERSION

version 0.002

# 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

## /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\_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 <preaction@cpan.org>

# 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.
