Skip to content

Commit 6fc76c1

Browse files
afrindmeta-codesync[bot]
authored andcommitted
moq-test client simplification
Summary: Remove some parent classes, methods and members that are unused Reviewed By: sharmafb Differential Revision: D86428305 fbshipit-source-id: d9a09482db61a369e1380273cb5aca41f9131f55
1 parent 6f73a8c commit 6fc76c1

2 files changed

Lines changed: 60 additions & 87 deletions

File tree

moxygen/moqtest/MoQTestClient.cpp

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ folly::coro::Task<void> MoQTestClient::connect(folly::EventBase* evb) {
4343
std::chrono::milliseconds(FLAGS_connect_timeout),
4444
std::chrono::seconds(FLAGS_transaction_timeout),
4545
nullptr,
46-
shared_from_this(),
46+
nullptr,
4747
quic::TransportSettings());
4848

4949
co_return;
@@ -53,10 +53,12 @@ void MoQTestClient::initialize() {
5353
// Create a receiver for the client
5454
subReceiver_ = std::make_shared<ObjectReceiver>(
5555
ObjectReceiver::SUBSCRIBE,
56-
std::shared_ptr<MoQTestClient>(shared_from_this()));
56+
std::shared_ptr<ObjectReceiverCallback>(
57+
std::shared_ptr<void>(), &objectReceiverCallback_));
5758
fetchReceiver_ = std::make_shared<ObjectReceiver>(
5859
ObjectReceiver::FETCH,
59-
std::shared_ptr<MoQTestClient>(shared_from_this()));
60+
std::shared_ptr<ObjectReceiverCallback>(
61+
std::shared_ptr<void>(), &objectReceiverCallback_));
6062
}
6163

6264
folly::coro::Task<moxygen::TrackNamespace> MoQTestClient::subscribe(
@@ -136,7 +138,7 @@ folly::coro::Task<moxygen::TrackNamespace> MoQTestClient::fetch(
136138
}
137139

138140
ObjectReceiverCallback::FlowControlState MoQTestClient::onObject(
139-
folly::Optional<TrackAlias> /* trackAlias */,
141+
const folly::Optional<TrackAlias>& /* trackAlias */,
140142
const ObjectHeader& objHeader,
141143
Payload payload) {
142144
XLOG(DBG1) << "MoQTest DEBUGGING: Calling onObject";
@@ -161,7 +163,7 @@ ObjectReceiverCallback::FlowControlState MoQTestClient::onObject(
161163
}
162164

163165
void MoQTestClient::onObjectStatus(
164-
folly::Optional<TrackAlias> /* trackAlias */,
166+
const folly::Optional<TrackAlias>& /* trackAlias */,
165167
const ObjectHeader& objHeader) {
166168
XLOG(DBG1) << "MoQTest DEBUGGING: calling onObjectStatus";
167169

@@ -201,7 +203,7 @@ void MoQTestClient::onEndOfStream() {
201203
void MoQTestClient::onError(ResetStreamErrorCode) {
202204
XLOG(DBG1) << "MoQTest DEBUGGING: calling onError";
203205
}
204-
void MoQTestClient::onSubscribeDone(SubscribeDone done) {
206+
void MoQTestClient::onSubscribeDone(const SubscribeDone& done) {
205207
XLOG(DBG1) << "MoQTest DEBUGGING: onSubscribeDone";
206208

207209
if (params_.forwardingPreference == ForwardingPreference::DATAGRAM) {
@@ -507,61 +509,8 @@ bool MoQTestClient::validateDatagramObjects(const ObjectHeader& header) {
507509
return true;
508510
}
509511

510-
void MoQTestClient::goaway(Goaway goaway) {
511-
XLOG(DBG1) << "MoQTest DEBUGGING: calling goaway";
512-
moqClient_->goaway(goaway);
513-
};
514-
515-
void MoQTestClient::announceCancel(
516-
AnnounceErrorCode errorCode,
517-
std::string reasonPhrase) {
518-
if (announceCallback_) {
519-
announceCallback_->announceCancel(errorCode, std::move(reasonPhrase));
520-
}
521-
}
522-
523-
folly::coro::Task<MoQSession::AnnounceResult> MoQTestClient::announce(
524-
Announce ann,
525-
std::shared_ptr<AnnounceCallback> callback) {
526-
LOG(INFO) << "MoQTest DEBUGGING: calling announce";
527-
auto track = convertMoqTestParamToTrackNamespace(&params_);
528-
529-
if (callback) {
530-
announceCallback_ = callback;
531-
}
532-
533-
if (track.hasError()) {
534-
AnnounceError error{
535-
requestID_,
536-
AnnounceErrorCode::INTERNAL_ERROR,
537-
"Parameters couldn't be converted to TrackNamespace"};
538-
co_return folly::makeUnexpected(error);
539-
}
540-
541-
AnnounceOk ok = {
542-
requestID_,
543-
{},
544-
};
545-
co_return std::make_shared<AnnounceHandle>(ok);
546-
}
547-
548512
folly::coro::Task<void> MoQTestClient::trackStatus(TrackStatus req) {
549513
co_await moqClient_->moqSession_->trackStatus(req);
550514
}
551515

552-
folly::coro::Task<Publisher::SubscribeAnnouncesResult>
553-
MoQTestClient::subscribeAnnounces(SubscribeAnnounces ann) {
554-
auto res = co_await moqClient_->moqSession_->subscribeAnnounces(ann);
555-
if (res.hasValue()) {
556-
subAnnouncesHandle_ = res.value();
557-
}
558-
co_return res;
559-
}
560-
561-
void MoQTestClient::unsubscribeAnnounces(UnsubscribeAnnounces unann) {
562-
if (subAnnouncesHandle_) {
563-
subAnnouncesHandle_->unsubscribeAnnounces();
564-
}
565-
}
566-
567516
} // namespace moxygen

moxygen/moqtest/MoQTestClient.h

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ enum AdjustedExpectedResult : int {
4040
ERROR_RECEIVING_DATA = 2
4141
};
4242

43-
class MoQTestClient : public moxygen::Subscriber,
44-
public std::enable_shared_from_this<MoQTestClient>,
45-
public ObjectReceiverCallback {
43+
class MoQTestClient {
4644
public:
4745
MoQTestClient(folly::EventBase* evb, proxygen::URL url);
4846

49-
~MoQTestClient() override {}
47+
~MoQTestClient() {}
5048

5149
MoQTestClient(const MoQTestClient&) = delete;
5250
MoQTestClient& operator=(const MoQTestClient&) = delete;
@@ -62,39 +60,66 @@ class MoQTestClient : public moxygen::Subscriber,
6260

6361
folly::coro::Task<moxygen::TrackNamespace> fetch(MoQTestParameters params);
6462

65-
// Override Vritual Functions for now to return basic print statements
66-
virtual FlowControlState onObject(
67-
folly::Optional<TrackAlias> trackAlias,
68-
const ObjectHeader& objHeader,
69-
Payload payload) override;
70-
virtual void onObjectStatus(
71-
folly::Optional<TrackAlias> trackAlias,
72-
const ObjectHeader& objHeader) override;
73-
virtual void onEndOfStream() override;
74-
virtual void onError(ResetStreamErrorCode) override;
75-
virtual void onSubscribeDone(SubscribeDone done) override;
76-
7763
void setLogger(const std::shared_ptr<MLogger>& logger);
7864

79-
virtual void goaway(Goaway goaway) override;
80-
virtual folly::coro::Task<AnnounceResult> announce(
81-
Announce ann,
82-
std::shared_ptr<AnnounceCallback> callback = nullptr) override;
83-
8465
folly::coro::Task<void> trackStatus(TrackStatus req);
8566
void subscribeUpdate(SubscribeUpdate update);
86-
folly::coro::Task<Publisher::SubscribeAnnouncesResult> subscribeAnnounces(
87-
SubscribeAnnounces announces);
88-
void unsubscribeAnnounces(UnsubscribeAnnounces unann);
89-
90-
void announceCancel(AnnounceErrorCode errorCode, std::string reasonPhrase);
9167

9268
private:
69+
// An ObjectReceiverCallback implementation that forwards calls to a
70+
// MoQTestClient.
71+
class ObjectReceiverCallback : public moxygen::ObjectReceiverCallback {
72+
public:
73+
explicit ObjectReceiverCallback(MoQTestClient& client) : client_(client) {}
74+
75+
FlowControlState onObject(
76+
folly::Optional<TrackAlias> trackAlias,
77+
const ObjectHeader& objHeader,
78+
Payload payload) override {
79+
return client_.onObject(
80+
std::move(trackAlias), objHeader, std::move(payload));
81+
}
82+
83+
void onObjectStatus(
84+
folly::Optional<TrackAlias> trackAlias,
85+
const ObjectHeader& objHeader) override {
86+
client_.onObjectStatus(std::move(trackAlias), objHeader);
87+
}
88+
89+
void onEndOfStream() override {
90+
client_.onEndOfStream();
91+
}
92+
93+
void onError(ResetStreamErrorCode code) override {
94+
client_.onError(code);
95+
}
96+
97+
void onSubscribeDone(SubscribeDone done) override {
98+
client_.onSubscribeDone(std::move(done));
99+
}
100+
101+
private:
102+
MoQTestClient& client_;
103+
};
104+
105+
// Override Vritual Functions for now to return basic print statements
106+
ObjectReceiverCallback::FlowControlState onObject(
107+
const folly::Optional<TrackAlias>& trackAlias,
108+
const ObjectHeader& objHeader,
109+
Payload payload);
110+
void onObjectStatus(
111+
const folly::Optional<TrackAlias>& trackAlias,
112+
const ObjectHeader& objHeader);
113+
void onEndOfStream();
114+
void onError(ResetStreamErrorCode);
115+
void onSubscribeDone(const SubscribeDone& done);
116+
117+
ObjectReceiverCallback objectReceiverCallback_{*this};
118+
93119
std::shared_ptr<MoQFollyExecutorImpl> moqExecutor_;
94120
std::unique_ptr<MoQClient> moqClient_;
95121
std::shared_ptr<ObjectReceiver> subReceiver_;
96122
std::shared_ptr<ObjectReceiver> fetchReceiver_;
97-
std::shared_ptr<AnnounceCallback> announceCallback_;
98123

99124
// Holds Current Request Parameters
100125
ReceivingType receivingType_ = ReceivingType::UNKNOWN_RECEIVING_TYPE;
@@ -117,7 +142,6 @@ class MoQTestClient : public moxygen::Subscriber,
117142
// Handles
118143
std::shared_ptr<Publisher::SubscriptionHandle> subHandle_;
119144
std::shared_ptr<Publisher::FetchHandle> fetchHandle_;
120-
std::shared_ptr<Publisher::SubscribeAnnouncesHandle> subAnnouncesHandle_;
121145

122146
// Subscription Data Validation functions
123147
void initializeExpecteds(MoQTestParameters& params);

0 commit comments

Comments
 (0)