Back to index

libsfml  1.6+dfsg2
Classes | Functions | Variables
Server.cpp File Reference
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <iomanip>
#include <iostream>

Go to the source code of this file.

Classes

class  NetworkAudioStream
 Customized sound stream for acquiring audio data from the network /////////////////////////////////////////////////////////. More...

Functions

void DoServer (unsigned short Port)
 Launch a server and wait for incoming audio data from a connected client.

Variables

const sf::Uint8 AudioData = 1
const sf::Uint8 EndOfStream = 2

Function Documentation

void DoServer ( unsigned short  Port)

Launch a server and wait for incoming audio data from a connected client.

/////////////////////////////////////////////////////////

Definition at line 185 of file Server.cpp.

{
    // Build an audio stream to play sound data as it is received through the network
    NetworkAudioStream AudioStream;
    AudioStream.Start(Port);

    // Loop until the sound playback is finished
    while (AudioStream.GetStatus() != sf::SoundStream::Stopped)
    {
        // Leave some CPU time for other threads
        sf::Sleep(0.1f);
    }

    std::cin.ignore(10000, '\n');

    // Wait until the user presses 'enter' key
    std::cout << "Press enter to replay the sound..." << std::endl;
    std::cin.ignore(10000, '\n');

    // Replay the sound (just to make sure replaying the received data is OK)
    AudioStream.Play();

    // Loop until the sound playback is finished
    while (AudioStream.GetStatus() != sf::SoundStream::Stopped)
    {
        // Leave some CPU time for other threads
        sf::Sleep(0.1f);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const sf::Uint8 AudioData = 1

Definition at line 11 of file Server.cpp.

const sf::Uint8 EndOfStream = 2

Definition at line 12 of file Server.cpp.