MCPcopy Create free account
hub / github.com/SFML/SFML / start

Method start

examples/voip/Server.cpp:44–69  ·  view source on GitHub ↗

/////////////////////////////////////////////////////// Run the server, stream audio data from the client ///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

42 ///
43 ////////////////////////////////////////////////////////////
44 void start(unsigned short port)
45 {
46 if (!m_hasFinished)
47 {
48 // Listen to the given port for incoming connections
49 if (m_listener.listen(port) != sf::Socket::Status::Done)
50 return;
51 std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
52
53 // Wait for a connection
54 if (m_listener.accept(m_client) != sf::Socket::Status::Done)
55 return;
56 std::cout << "Client connected: " << m_client.getRemoteAddress().value() << std::endl;
57
58 // Start playback
59 play();
60
61 // Start receiving audio data
62 receiveLoop();
63 }
64 else
65 {
66 // Start playback
67 play();
68 }
69 }
70
71private:
72 ////////////////////////////////////////////////////////////

Callers 2

doServerFunction · 0.45
doClientFunction · 0.45

Calls 3

listenMethod · 0.80
acceptMethod · 0.80
getRemoteAddressMethod · 0.80

Tested by

no test coverage detected