class Sock::Client
Public Class Methods
new(name: DEFAULT_NAME, logger: Logger.new(STDOUT), redis: Redis.new)
click to toggle source
# File lib/sock/client.rb, line 4 def initialize(name: DEFAULT_NAME, logger: Logger.new(STDOUT), redis: Redis.new) @logger = logger @name = name @redis = redis end
Public Instance Methods
pub(msg, channel: '')
click to toggle source
send a message to all subscribed listeners.
# File lib/sock/client.rb, line 13 def pub(msg, channel: '') @logger.info "sending #{msg} on channel: #{channel_name(channel)}" @redis.publish(channel_name(channel), msg) end
Private Instance Methods
channel_name(postfix)
click to toggle source
# File lib/sock/client.rb, line 20 def channel_name(postfix) "#{@name}/#{postfix}" end