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

Commit d155d96

Browse files
authored
Add a new event OnDatagramReceived for WebTransportServerSession. (#58)
This is a breaking change as a new pure virtual function OnDatagramReceived is added to WebTransportSessionInterface::Visitor. All derived classes must implement this function.
1 parent 7e8c661 commit d155d96

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

web_transport/sdk/api/owt/quic/web_transport_session_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class OWT_EXPORT WebTransportSessionInterface {
2121
virtual void OnIncomingStream(WebTransportStreamInterface*) = 0;
2222
virtual void OnCanCreateNewOutgoingStream(bool unidirectional) = 0;
2323
virtual void OnConnectionClosed() = 0;
24+
virtual void OnDatagramReceived(const uint8_t* data, size_t length) = 0;
2425
};
2526
virtual ~WebTransportSessionInterface() = default;
2627
virtual const char* ConnectionId() const = 0;

web_transport/sdk/impl/tests/web_transport_echo_visitors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SessionEchoVisitor : public WebTransportSessionInterface::Visitor {
3535
void OnCanCreateNewOutgoingStream(bool) override {}
3636
void OnConnectionClosed() override {}
3737
void OnIncomingStream(WebTransportStreamInterface* stream) override;
38+
void OnDatagramReceived(const uint8_t* data, size_t length) override {}
3839

3940
private:
4041
std::vector<std::unique_ptr<StreamEchoVisitor>> stream_visitors_;

web_transport/sdk/impl/web_transport_server_session.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,12 @@ void WebTransportServerSession::AcceptIncomingStream(
224224
}
225225
}
226226

227+
void WebTransportServerSession::OnDatagramReceived(absl::string_view datagram) {
228+
if (visitor_) {
229+
visitor_->OnDatagramReceived(
230+
reinterpret_cast<const uint8_t*>(datagram.data()), datagram.size());
231+
}
232+
}
233+
227234
} // namespace quic
228235
} // namespace owt

web_transport/sdk/impl/web_transport_server_session.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class WebTransportServerSession : public WebTransportSessionInterface,
5050
const std::string& error_message) override;
5151
void OnIncomingBidirectionalStreamAvailable() override;
5252
void OnIncomingUnidirectionalStreamAvailable() override;
53-
void OnDatagramReceived(absl::string_view datagram) override {}
53+
void OnDatagramReceived(absl::string_view datagram) override;
5454
void OnCanCreateNewOutgoingUnidirectionalStream() override {}
5555
void OnCanCreateNewOutgoingBidirectionalStream() override {}
5656

0 commit comments

Comments
 (0)