Class: IRuby::SessionAdapter::TestAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- IRuby::SessionAdapter::TestAdapter
- Includes:
- IRuby::SessionSerialize
- Defined in:
- lib/iruby/session_adapter/test_adapter.rb
Defined Under Namespace
Classes: DummySocket
Constant Summary
Constants included from IRuby::SessionSerialize
IRuby::SessionSerialize::DELIM
Instance Attribute Summary collapse
-
#recv_callback ⇒ Object
Returns the value of attribute recv_callback.
-
#send_callback ⇒ Object
Returns the value of attribute send_callback.
Instance Method Summary collapse
- #heartbeat_loop(sock) ⇒ Object
-
#initialize(config) ⇒ TestAdapter
constructor
A new instance of TestAdapter.
- #recv(sock) ⇒ Object
- #send(sock, data) ⇒ Object
Methods inherited from BaseAdapter
available?, load_requirements, #make_pub_socket, #make_rep_socket, #make_router_socket, #name
Constructor Details
#initialize(config) ⇒ TestAdapter
Returns a new instance of TestAdapter.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/iruby/session_adapter/test_adapter.rb', line 10 def initialize(config) super unless config['key'].empty? || config['signature_scheme'].empty? unless config['signature_scheme'] =~ /\Ahmac-/ raise "Unknown signature_scheme: #{config['signature_scheme']}" end digest_algorithm = config['signature_scheme'][/\Ahmac-(.*)\Z/, 1] @hmac = OpenSSL::HMAC.new(config['key'], OpenSSL::Digest.new(digest_algorithm)) end @send_callback = nil @recv_callback = nil end |
Instance Attribute Details
#recv_callback ⇒ Object
Returns the value of attribute recv_callback.
25 26 27 |
# File 'lib/iruby/session_adapter/test_adapter.rb', line 25 def recv_callback @recv_callback end |
#send_callback ⇒ Object
Returns the value of attribute send_callback.
25 26 27 |
# File 'lib/iruby/session_adapter/test_adapter.rb', line 25 def send_callback @send_callback end |
Instance Method Details
#heartbeat_loop(sock) ⇒ Object
39 40 |
# File 'lib/iruby/session_adapter/test_adapter.rb', line 39 def heartbeat_loop(sock) end |
#recv(sock) ⇒ Object
33 34 35 36 37 |
# File 'lib/iruby/session_adapter/test_adapter.rb', line 33 def recv(sock) unless @recv_callback.nil? serialize(@recv_callback.call(sock)) end end |
#send(sock, data) ⇒ Object
27 28 29 30 31 |
# File 'lib/iruby/session_adapter/test_adapter.rb', line 27 def send(sock, data) unless @send_callback.nil? @send_callback.call(sock, unserialize(data)) end end |