Skip to content

Commit 8640364

Browse files
Sujay Patelfacebook-github-bot
Sujay Patel
authored andcommitted
Publisher Skeleton With main method to connect to MoQTestServer
Summary: Added a MoqTestServer class that inherits from Publisher and MoQServer to test against MoQTextClient. Reviewed By: sharmafb Differential Revision: D75325041 fbshipit-source-id: f2b9f013ab8885959d6be80860d17d304ce5e055
1 parent 29815d6 commit 8640364

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

moxygen/moqtest/MoQTestServer.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
2+
3+
#include "moxygen/moqtest/MoQTestServer.h"
4+
5+
std::string kCert = "fake_cert";
6+
std::string kKey = "fake_key";
7+
std::string kEndpointName = "fake_endpoint";
8+
9+
namespace moxygen {
10+
11+
MoQTestServer::MoQTestServer(uint16_t port)
12+
: MoQServer(port, kCert, kKey, kEndpointName) {}
13+
14+
} // namespace moxygen
15+
16+
DEFINE_int32(port, 9999, "Port to listen on");
17+
18+
int main(int argc, char** argv) {
19+
gflags::ParseCommandLineFlags(&argc, &argv, false);
20+
folly::Init init(&argc, &argv);
21+
22+
// Initialize Server with correct port
23+
auto server = std::make_shared<moxygen::MoQTestServer>(FLAGS_port);
24+
25+
std::cout << "\nEnter anything to exit." << std::endl;
26+
std::string input;
27+
std::getline(std::cin, input);
28+
std::cout << "\nExiting." << std::endl;
29+
30+
return 0;
31+
}

moxygen/moqtest/MoQTestServer.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
2+
3+
#pragma once
4+
5+
#include "moxygen/MoQServer.h"
6+
#include "moxygen/Publisher.h"
7+
8+
namespace moxygen {
9+
10+
class MoQTestServer : public moxygen::Publisher,
11+
public moxygen::MoQServer,
12+
public std::enable_shared_from_this<MoQTestServer> {
13+
public:
14+
MoQTestServer(uint16_t port);
15+
16+
// Override onNewSession to set publisher handler to be this object
17+
virtual void onNewSession(
18+
std::shared_ptr<MoQSession> clientSession) override {
19+
clientSession->setPublishHandler(shared_from_this());
20+
}
21+
22+
private:
23+
};
24+
25+
} // namespace moxygen

0 commit comments

Comments
 (0)