class Eddn::Client

Constants

VERSION

Public Class Methods

new(url="tcp://eddn-relay.elite-markets.net:9500", opts={}) click to toggle source
# File lib/eddn/client.rb, line 8
def initialize url="tcp://eddn-relay.elite-markets.net:9500", opts={}
  @url = url
  @opts = opts
end

Public Instance Methods

connect() click to toggle source
# File lib/eddn/client.rb, line 12
def connect
  @subscriber = context.socket ZMQ::SUB
  @subscriber.connect(@url)
  @subscriber.setsockopt(ZMQ::SUBSCRIBE, "")

  @poller = ZMQ::Poller.new
  @poller.register(@subscriber, ZMQ::POLLIN)
end
poll() click to toggle source
# File lib/eddn/client.rb, line 26
def poll
  p = @poller.poll
  if p
    @subscriber.recv_string(msec ='')
    inflate = Zlib::Inflate.new
    return JSON.parse(Zlib::Inflate.inflate(msec))
  else
    return nil
  end
end
poll_blocking() click to toggle source
# File lib/eddn/client.rb, line 22
def poll_blocking
  while (data = poll).nil?; sleep 0.001; end
  return data
end

Private Instance Methods

context() click to toggle source
# File lib/eddn/client.rb, line 37
def context
  @context ||= ZMQ::Context.new
end