Class: QuietQUIC::Connection
- Inherits:
-
Object
- Object
- QuietQUIC::Connection
- Defined in:
- lib/quietquic/connection.rb
Overview
A single post-handshake, PSK-authenticated QUIC connection.
Produced identically by Server#accept and QuietQUIC::Client.connect (both sides
surface the same type). Carries bidirectional Streams: #open_stream
dials a new stream, #accept_stream awaits the next peer-opened one. Both
park the fiber (under an Async reactor) until they resolve.
Dropping a Connection does not tear the connection down; call #close to
send a CONNECTION_CLOSE so the peer tears down promptly rather than idling
out.
Instance Method Summary collapse
-
#accept_stream ⇒ Stream
Await and return the next bidirectional Stream the peer opens.
-
#close ⇒ void
Close the connection, sending a CONNECTION_CLOSE frame so the peer tears down promptly.
-
#initialize(native) ⇒ Connection
constructor
A new instance of Connection.
-
#open_stream ⇒ Stream
Open a new bidirectional Stream.
-
#remote_address ⇒ String
The remote peer's address (e.g.
"127.0.0.1:54321").
Constructor Details
#initialize(native) ⇒ Connection
Returns a new instance of Connection.
15 16 17 |
# File 'lib/quietquic/connection.rb', line 15 def initialize(native) @native = native end |
Instance Method Details
#accept_stream ⇒ Stream
Await and return the next bidirectional Stream the peer opens.
Blocks until the peer initiates a stream. Under an Async reactor it
parks the fiber; otherwise it blocks with the GVL released.
36 37 38 |
# File 'lib/quietquic/connection.rb', line 36 def accept_stream Stream.new(QuietQUIC.await(@native.accept_stream_op)) end |
#close ⇒ void
This method returns an undefined value.
Close the connection, sending a CONNECTION_CLOSE frame so the peer tears down promptly. Best-effort and idempotent.
51 52 53 |
# File 'lib/quietquic/connection.rb', line 51 def close @native.close end |
#open_stream ⇒ Stream
Open a new bidirectional Stream.
24 25 26 |
# File 'lib/quietquic/connection.rb', line 24 def open_stream Stream.new(QuietQUIC.await(@native.open_stream_op)) end |
#remote_address ⇒ String
The remote peer's address (e.g. "127.0.0.1:54321").
43 44 45 |
# File 'lib/quietquic/connection.rb', line 43 def remote_address @native.remote_address end |