class Pantry::Communication::SubscribeSocket
The SubscribeSocket
manages the Subscription side of the Pub/Sub channel, using a 0MQ PUB socket. This socket can subscribe to any number of streams depending on the filtering given. Messages received by this socket are passed to the configured listener as Messages.
Public Class Methods
new(host, port, security)
click to toggle source
Calls superclass method
Pantry::Communication::ReadingSocket::new
# File lib/pantry/communication/subscribe_socket.rb, line 10 def initialize(host, port, security) super @filter = ClientFilter.new end
Public Instance Methods
build_socket()
click to toggle source
# File lib/pantry/communication/subscribe_socket.rb, line 19 def build_socket Celluloid::ZMQ::SubSocket.new end
filter_on(client_filter)
click to toggle source
# File lib/pantry/communication/subscribe_socket.rb, line 15 def filter_on(client_filter) @filter = client_filter end
open_socket(socket)
click to toggle source
# File lib/pantry/communication/subscribe_socket.rb, line 23 def open_socket(socket) socket.connect("tcp://#{host}:#{port}") @filter.streams.each do |stream| socket.subscribe(stream) end end