module AgentZMQ::BaseAgent

Attributes

end_point[RW]
end_point_type[RW]
name[R]
socket_opts[RW]

Public Instance Methods

zmq_context() click to toggle source
# File lib/agent_zmq/agents/base_agent.rb, line 6
def zmq_context
  @ctx ||= ZMQ::Context.new 1
end
zmq_socket() click to toggle source
# File lib/agent_zmq/agents/base_agent.rb, line 10
def zmq_socket
  return @sub_socket unless @sub_socket.nil?

  (@sub_socket = sock_type).tap do

    case @end_point_type 
      when :connect
        @sub_socket.connect(@end_point) 
      else
        @sub_socket.bind(@end_point) 
    end

    if @socket_opts.is_a? Array
      @socket_opts.each do |opts|
        opts.each_pair do |opt_name, opt_val|
          @sub_socket.setsockopt(opt_name,opt_val)
        end
      end
    end
  end
end