Sha256: d187bfabbd657f051a6b2977c0d915a13c7480d6982432000875c1b223885f07
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
require_relative 'websocket' require_relative 'config' module Pakyow module Realtime # Deals with realtime connections in context of an app. Instances are # returned by the `socket` helper method during routing. # # @api public class Context # @api private def initialize(app) @app = app end # Subscribe the current session's connection to one or more channels. # # @api public def subscribe(*channels) channels = Array.ensure(channels).flatten fail ArgumentError if channels.empty? delegate.subscribe( @app.socket_digest(@app.socket_connection_id), channels ) end # Unsubscribe the current session's connection to one or more channels. # # @api public def unsubscribe(*channels) channels = Array.ensure(channels).flatten fail ArgumentError if channels.empty? delegate.unsubscribe( @app.socket_digest(@app.socket_connection_id), channels ) end # Push a message down one or more channels. # # @api public def push(msg, *channels) channels = Array.ensure(channels).flatten fail ArgumentError if channels.empty? delegate.push(msg, channels) end # Returns an instance of the connection delegate. # # @api private def delegate Delegate.instance end end end end
Version data entries
3 entries across 3 versions & 1 rubygems