Class: DripDrop::ZMQBaseHandler

Inherits:
BaseHandler show all
Defined in:
lib/dripdrop/handlers/zeromq.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#handle_error, #on_error, #print_exception

Constructor Details

#initialize(opts = {}) ⇒ ZMQBaseHandler

Returns a new instance of ZMQBaseHandler.



17
18
19
20
21
22
# File 'lib/dripdrop/handlers/zeromq.rb', line 17

def initialize(opts={})
  @opts         = opts
  @connection   = nil
  @msg_format   = opts[:msg_format] || :dripdrop
  @message_class = @opts[:message_class] || DripDrop.default_message_class
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



15
16
17
# File 'lib/dripdrop/handlers/zeromq.rb', line 15

def connection
  @connection
end

Instance Method Details

#add_connection(connection) ⇒ Object



24
25
26
# File 'lib/dripdrop/handlers/zeromq.rb', line 24

def add_connection(connection)
  @connection = connection
end

#addressObject



46
47
48
# File 'lib/dripdrop/handlers/zeromq.rb', line 46

def address
  self.connection.address
end

#on_receive(msg_format = :dripdrop, &block) ⇒ Object



36
37
38
39
# File 'lib/dripdrop/handlers/zeromq.rb', line 36

def on_receive(msg_format=:dripdrop,&block)
  @recv_cbak = block
  self
end

#on_recv(*args, &block) ⇒ Object



41
42
43
44
# File 'lib/dripdrop/handlers/zeromq.rb', line 41

def on_recv(*args,&block)
  $stderr.write "DripDrop Warning :on_recv is deprecated in favor of :on_receive"
  on_receive(*args,&block)
end

#post_setupObject

Triggered after a handler is setup



51
# File 'lib/dripdrop/handlers/zeromq.rb', line 51

def post_setup; end

#read_connectionObject



28
29
30
# File 'lib/dripdrop/handlers/zeromq.rb', line 28

def read_connection
  @connection
end

#write_connectionObject



32
33
34
# File 'lib/dripdrop/handlers/zeromq.rb', line 32

def write_connection
  @connection
end