Sha256: 3a5554f4cf084292a54843e4d0ff0d3724fc89b3d25695bac97f859cd25dc072

Contents?: true

Size: 912 Bytes

Versions: 2

Compression:

Stored size: 912 Bytes

Contents

require_relative 'cable'

module Hippo
    module API

        class PubSub < Cable::Channel
            identifier :pubsub

            PREFIX = 'ps:'

            def on(data)
                Hippo.logger.info "pubsub  on: #{data['channel']}"
                stream_from channel_prefix + data['channel']
            end

            def off(data)
                Hippo.logger.info "pubsub off: #{data['channel']}"
                stop_stream channel_prefix + data['channel']
            end

            def self.publish(channel, data)
                Hippo.logger.info "pubsub pub: #{channel}"
                channel = channel_prefix + channel
                LiteCable.broadcast(channel, data.merge(channel: channel))
            end

            def self.channel_prefix
                PREFIX
            end

            def channel_prefix
                PREFIX
            end

        end

    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hippo-fw-0.9.5 lib/hippo/api/pub_sub.rb
hippo-fw-0.9.4 lib/hippo/api/pub_sub.rb