1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-09 20:42:44 +03:00
Files
mvfst/quic/server/async_tran/QuicServerAsyncTransport.cpp
Andrii Vasylevskyi 7204c8c46e QUIC client and server AsyncTransport wrappers
Summary:
Helper classes for easy experimentation with QUIC in existing code using folly::AsyncSockets, using single QUIC bidi stream.
1) QuicStreamAsyncTransport buffers writes/read callback assignment until stream id is assigned. This similar to AsyncSocket that handles connect() internally and allows consumers to read/write right away after instance creation.
2) Quic(Client|Server)AsyncTransport handle connection level callbacks and update stream id on corresponding stream event
3) QuicAsyncTransportAcceptor and QuicAsyncTransportServer handle wangle::ManagedConnections, which are commonly used with folly::AsyncServerSockets

Reviewed By: yangchi

Differential Revision: D24656620

fbshipit-source-id: 75f9eb66c6cc8b7b1b974912d760c8aae5a5809f
2020-11-30 13:14:24 -08:00

51 lines
1.4 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
#include <quic/server/async_tran/QuicServerAsyncTransport.h>
#include <folly/Conv.h>
namespace quic {
void QuicServerAsyncTransport::setServerSocket(
std::shared_ptr<quic::QuicSocket> sock) {
setSocket(std::move(sock));
}
void QuicServerAsyncTransport::onNewBidirectionalStream(StreamId id) noexcept {
if (id != 0) {
CHECK(false) << "Only single stream 0 is supported";
}
setStreamId(id);
}
void QuicServerAsyncTransport::onNewUnidirectionalStream(
StreamId /*id*/) noexcept {
CHECK(false) << "Unidirectional stream not supported";
}
void QuicServerAsyncTransport::onStopSending(
StreamId /*id*/,
ApplicationErrorCode /*error*/) noexcept {}
void QuicServerAsyncTransport::onConnectionEnd() noexcept {
folly::AsyncSocketException ex(
folly::AsyncSocketException::UNKNOWN, "Quic connection ended");
closeNowImpl(std::move(ex));
}
void QuicServerAsyncTransport::onConnectionError(
std::pair<QuicErrorCode, std::string> code) noexcept {
folly::AsyncSocketException ex(
folly::AsyncSocketException::UNKNOWN,
folly::to<std::string>("Quic connection error", code.second));
closeNowImpl(std::move(ex));
}
void QuicServerAsyncTransport::onTransportReady() noexcept {}
} // namespace quic