Class: IRuby::SessionAdapter::FfirzmqAdapter
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseAdapter
available?, #initialize, #make_pub_socket, #make_rep_socket, #make_router_socket, #name
Class Method Details
.load_requirements ⇒ Object
4
5
6
|
# File 'lib/iruby/session_adapter/ffirzmq_adapter.rb', line 4
def self.load_requirements
require 'ffi-rzmq'
end
|
Instance Method Details
#heartbeat_loop(sock) ⇒ Object
28
29
30
|
# File 'lib/iruby/session_adapter/ffirzmq_adapter.rb', line 28
def heartbeat_loop(sock)
@heartbeat_device = ZMQ::Device.new(sock, sock)
end
|
#recv(sock) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/iruby/session_adapter/ffirzmq_adapter.rb', line 14
def recv(sock)
msg = []
while msg.empty? || sock.more_parts?
begin
frame = ''
rc = sock.recv_string(frame)
ZMQ::Util.error_check('zmq_msg_recv', rc)
msg << frame
rescue
end
end
msg
end
|
#send(sock, data) ⇒ Object
8
9
10
11
12
|
# File 'lib/iruby/session_adapter/ffirzmq_adapter.rb', line 8
def send(sock, data)
data.each_with_index do |part, i|
sock.send_string(part, i == data.size - 1 ? 0 : ZMQ::SNDMORE)
end
end
|