Class: Librevox::Client
- Inherits:
-
Object
- Object
- Librevox::Client
- Defined in:
- lib/librevox/client.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #connect(socket) ⇒ Object
-
#initialize(handler, endpoint, **options) ⇒ Client
constructor
A new instance of Client.
- #run ⇒ Object
Constructor Details
#initialize(handler, endpoint, **options) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/librevox/client.rb', line 7 def initialize(handler, endpoint, **) @handler = handler @endpoint = endpoint @options = end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
13 14 15 |
# File 'lib/librevox/client.rb', line 13 def endpoint @endpoint end |
Instance Method Details
#connect(socket) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/librevox/client.rb', line 15 def connect(socket) stream = IO::Stream(socket) connection = Protocol::Connection.new(stream) listener = @handler.new(connection, @options) session_task = Async { listener.run_session } connection.read_loop { |msg| listener.(msg) } ensure session_task&.stop connection.close end |