Class: BlastBeat::Node
- Inherits:
-
Object
- Object
- BlastBeat::Node
- Defined in:
- lib/blastbeat.rb
Instance Method Summary collapse
-
#initialize(server, nodename, threads = 1) ⇒ Node
constructor
A new instance of Node.
- #recv ⇒ Object
- #send(sid, msg_type, msg_body = '') ⇒ Object
- #uwsgi(pkt) ⇒ Object
Constructor Details
#initialize(server, nodename, threads = 1) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 11 |
# File 'lib/blastbeat.rb', line 6 def initialize(server, nodename, threads=1) @context = ZMQ::Context.create(threads) @socket = @context.socket(ZMQ::DEALER) @socket.setsockopt(ZMQ::IDENTITY, nodename) @socket.connect(server) end |
Instance Method Details
#recv ⇒ Object
13 14 15 16 17 |
# File 'lib/blastbeat.rb', line 13 def recv parts = [] @socket.recv_strings(parts) parts end |
#send(sid, msg_type, msg_body = '') ⇒ Object
19 20 21 |
# File 'lib/blastbeat.rb', line 19 def send(sid, msg_type, msg_body='') @socket.send_strings([sid, msg_type, msg_body]) end |
#uwsgi(pkt) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/blastbeat.rb', line 23 def uwsgi(pkt) ulen, = pkt[1,2].unpack('v') pos = 4 h = Hash.new while pos < ulen klen, = pkt[pos,2].unpack('v') k = pkt[pos+2, klen] pos += 2+klen vlen, = pkt[pos,2].unpack('v') v = pkt[pos+2, vlen] pos += 2+vlen h[k] = v end h end |