Module: Farcall::TransportBase
- Included in:
- BossTransport, JsonTransport
- Defined in:
- lib/farcall/json_transport.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#close_connection ⇒ Object
close connection (socket or streams).
-
#setup_streams(input: nil, output: nil, socket: nil) ⇒ Object
connect socket or use streams if any.
Instance Method Details
#close_connection ⇒ Object
close connection (socket or streams)
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/farcall/json_transport.rb', line 68 def close_connection if @socket if !@socket.closed? begin @socket.flush @socket.shutdown rescue Errno::ENOTCONN end @socket.close end @socket = nil else @input.close @output.close end @input = @output = nil end |
#setup_streams(input: nil, output: nil, socket: nil) ⇒ Object
connect socket or use streams if any
57 58 59 60 61 62 63 64 65 |
# File 'lib/farcall/json_transport.rb', line 57 def setup_streams input: nil, output: nil, socket: nil if socket @socket = socket @input = @output = SocketStream.new(socket) else @input, @output = input, output end @input != nil && @output != nil or raise Farcall::Error, "can't setup streams" end |