Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bparser integration + Stream construction/queueing #47

Merged
merged 5 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions include/quic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "quic/messages.hpp"
#include "quic/network.hpp"
#include "quic/opt.hpp"
#include "quic/parser.hpp"
#include "quic/stream.hpp"
#include "quic/types.hpp"
#include "quic/udp.hpp"
Expand Down
17 changes: 17 additions & 0 deletions include/quic/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,20 @@ namespace oxen::quic
class connection_interface : public std::enable_shared_from_this<connection_interface>
{
protected:
virtual std::shared_ptr<Stream> queue_stream_impl(
std::function<std::shared_ptr<Stream>(Connection& c, Endpoint& e)> make_stream) = 0;
virtual std::shared_ptr<Stream> get_new_stream_impl(
std::function<std::shared_ptr<Stream>(Connection& c, Endpoint& e)> make_stream) = 0;

public:
template <typename StreamT = Stream, typename... Args, std::enable_if_t<std::is_base_of_v<Stream, StreamT>, int> = 0>
std::shared_ptr<Stream> queue_stream(Args&&... args)
{
return queue_stream_impl([&](Connection& c, Endpoint& e) {
return std::make_shared<StreamT>(c, e, std::forward<Args>(args)...);
});
}

template <typename StreamT = Stream, typename... Args, std::enable_if_t<std::is_base_of_v<Stream, StreamT>, int> = 0>
std::shared_ptr<Stream> get_new_stream(Args&&... args)
{
Expand Down Expand Up @@ -153,6 +163,9 @@ namespace oxen::quic

TLSSession* get_session() { return tls_session.get(); };

std::shared_ptr<Stream> queue_stream_impl(
std::function<std::shared_ptr<Stream>(Connection& c, Endpoint& e)> make_stream) override;

std::shared_ptr<Stream> get_new_stream_impl(
std::function<std::shared_ptr<Stream>(Connection& c, Endpoint& e)> make_stream) override;

Expand Down Expand Up @@ -249,6 +262,10 @@ namespace oxen::quic

// holds a mapping of active streams
std::map<int64_t, std::shared_ptr<Stream>> streams;
std::map<int64_t, std::shared_ptr<Stream>> stream_queue;

int64_t next_incoming_stream_id = is_outbound() ? 1 : 0;

// datagram "pseudo-stream"
std::unique_ptr<DatagramIO> datagrams;
// "pseudo-stream" to represent ngtcp2 stream ID -1
Expand Down