Class: ProxyLocal::Client
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- ProxyLocal::Client
- Includes:
- EventMachine::Protocols::ObjectProtocol
- Defined in:
- lib/client.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.run(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/client.rb', line 23 def self.run( = {}) trap "SIGCLD", "IGNORE" trap "INT" do puts EventMachine.run exit end EventMachine.run do EventMachine::connect([:server_host], [:server_port], self) do |c| c.instance_eval do @options = send_object(BERT::Tuple[:options, @options]) end end end end |
Instance Method Details
#receive_object(message) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/client.rb', line 41 def receive_object() = [] unless .is_a?(Array) case [0] when :message puts [1] when :halt EventMachine.stop_event_loop when :request _, uuid, request = EventMachine::connect('127.0.0.1', @options[:local_port], ClientProxy) do |connection| connection.callback do |data| send_object(BERT::Tuple[:response, uuid, data]) end connection.send_data(request) end end end |
#serializer ⇒ Object
19 20 21 |
# File 'lib/client.rb', line 19 def serializer Serializer end |
#unbind ⇒ Object
60 61 62 63 |
# File 'lib/client.rb', line 60 def unbind EventMachine.stop_event_loop puts "A connection has been terminated" end |