Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 4fda6ee

Browse files
authored
Add OnConnectionClosed event. (#19)
* Add CanWrite method. * Working on connection closed event. * Call QuicTransportServerSession::OnConnectionClosed. QuicTransportOwtServerSession calls its base class to respond connection termination.
1 parent b4036e7 commit 4fda6ee

6 files changed

+20
-0
lines changed

quic_transport/api/owt/quic/quic_transport_session_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class OWT_EXPORT QuicTransportSessionInterface {
2020
virtual ~Visitor() = default;
2121
virtual void OnIncomingStream(QuicTransportStreamInterface*) = 0;
2222
virtual void OnCanCreateNewOutgoingStream(bool unidirectional) = 0;
23+
virtual void OnConnectionClosed() = 0;
2324
};
2425
virtual ~QuicTransportSessionInterface() = default;
2526
virtual const char* ConnectionId() const = 0;

quic_transport/api/owt/quic/quic_transport_stream_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class OWT_EXPORT QuicTransportStreamInterface {
4343
virtual void Close() = 0;
4444
// Bytes of data buffered.
4545
virtual uint64_t BufferedDataBytes() const = 0;
46+
// Ready to write new data.
47+
virtual bool CanWrite() const = 0;
4648
};
4749
} // namespace quic
4850
} // namespace owt

quic_transport/impl/quic_transport_owt_server_session.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,14 @@ const ConnectionStats& QuicTransportOwtServerSession::GetStats() {
189189
return stats_;
190190
}
191191

192+
void QuicTransportOwtServerSession::OnConnectionClosed(
193+
const ::quic::QuicConnectionCloseFrame& frame,
194+
::quic::ConnectionCloseSource source) {
195+
::quic::QuicTransportServerSession::OnConnectionClosed(frame, source);
196+
if (visitor_) {
197+
visitor_->OnConnectionClosed();
198+
}
199+
}
200+
192201
} // namespace quic
193202
} // namespace owt

quic_transport/impl/quic_transport_owt_server_session.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class QuicTransportOwtServerSession
5858
QuicTransportStreamInterface* CreateBidirectionalStream() override;
5959
const ConnectionStats& GetStats() override;
6060

61+
void OnConnectionClosed(const ::quic::QuicConnectionCloseFrame& frame,
62+
::quic::ConnectionCloseSource source) override;
63+
6164
protected:
6265
void OnIncomingDataStream(::quic::QuicTransportStream* stream) override;
6366
void OnCanCreateNewOutgoingStream(bool unidirectional) override;

quic_transport/impl/quic_transport_stream_impl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,9 @@ uint64_t QuicTransportStreamImpl::BufferedDataBytes() const {
175175
return stream_->BufferedDataBytes();
176176
}
177177

178+
bool QuicTransportStreamImpl::CanWrite() const {
179+
return stream_->CanWrite();
180+
}
181+
178182
} // namespace quic
179183
} // namespace owt

quic_transport/impl/quic_transport_stream_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class QuicTransportStreamImpl : public QuicTransportStreamInterface,
4343
size_t ReadableBytes() const override;
4444
void Close() override;
4545
uint64_t BufferedDataBytes() const override;
46+
bool CanWrite() const override;
4647

4748
// Overrides ::quic::QuicTransportStream::Visitor.
4849
void OnCanRead() override;

0 commit comments

Comments
 (0)