MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / main

Function main

src/test/test_server.cpp:103–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102
103int main() {
104 // Handle command-line input.
105 // The test configuration for the test server is setup using global variables, which are
106 // defined here.
107 Sarge sarge;
108 sarge.setArgument("h", "help", "Get this help message.", false);
109 sarge.setArgument("v", "version", "Output the NymphCast server version and exit.", false);
110 sarge.setArgument("f", "file", "Name of file to stream to remote receiver.", true);
111 sarge.setArgument("i", "ip", "IP address of the target NymphCast receiver.", true);
112 sarge.setDescription("NymphCast test server. For testing NymphCast functions.");
113 sarge.setUsage("test_server <options>");
114
115 sarge.parseArguments(argc, argv);
116
117 if (sarge.flagCount() == 0) {
118 sarge.printHelp();
119 return 0;
120 }
121
122 if (sarge.exists("help")) {
123 sarge.printHelp();
124 return 0;
125 }
126
127 if (sarge.exists("version")) {
128 std::cout << "NymphCast client version: " << __VERSION << std::endl;
129 return 0;
130 }
131
132
133 std::cout << "Starting test server..." << std::endl;
134
135 // Initialise the server.
136 long timeout = 5000; // 5 seconds.
137 NymphRemoteClient::init(logFunction, NYMPH_LOG_LEVEL_TRACE, timeout);
138
139 // Define all of the RPC methods we want to export for clients.
140 std::cout << "Registering methods...\n";
141 std::vector<NymphTypes> parameters;
142
143 // Client connects to server.
144 // bool connect(string client_id)
145 parameters.push_back(NYMPH_STRING);
146 NymphMethod connectFunction("connect", parameters, NYMPH_BOOL);
147 connectFunction.setCallback(connectClient);
148 NymphRemoteClient::registerMethod("connect", connectFunction);
149
150 // Client disconnects from server.
151 // bool disconnect()
152 parameters.clear();
153 NymphMethod disconnectFunction("disconnect", parameters, NYMPH_BOOL);
154 disconnectFunction.setCallback(disconnect);
155 NymphRemoteClient::registerMethod("disconnect", disconnectFunction);
156
157 // Client sends a chunk of track data.
158 // Returns: OK (0), ERROR (1).
159 // int session_data(string buffer)
160 parameters.clear();

Callers

nothing calls this directly

Calls 13

initFunction · 0.85
push_backMethod · 0.80
setCallbackMethod · 0.80
lockMethod · 0.80
waitMethod · 0.80
setArgumentMethod · 0.45
setDescriptionMethod · 0.45
setUsageMethod · 0.45
parseArgumentsMethod · 0.45
flagCountMethod · 0.45
printHelpMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected