This Voice Sample demonstrates how to implement a secure voice chat system using a client and server application for the C SDK.
The sample includes the following features:
- Requesting a token to allow a user to join a room with other users (via Server)
- Joining a room with friends or other users
- Leaving a room
- Muting your own audio
- Muting other user’s audio (via Server and only allowed by the room owner)
- Kicking another user from the room (via Server and only allowed by the room owner)
- Showing status updates when a user is speaking or muted
- Changing audio input and output devices
Voice Client
Setup for Windows 32/64-bit
This section covers building and running the Voice Client sample app for both 32-bit and 64-bit Windows operating systems.
Building the Voice Client Sample App for Win64/Win32
- Unzip
EOS-SDK.zip
into your location of choice. - Navigate to EOS-SDK > Samples.
- Double-click
Samples.sln
. Visual Studio will open with it in the Solution Explorer. - Set the StartUp Project to Voice.
- Open
SampleConstants.h
and update the ProductId, SandboxId, DeploymentId, ClientCredentialsId, and ClientCredentialsSecret based on the values for your Test App. - Select the solution configuration:
Release_DX
orDebug_DX
. - Select the solution platform: x64 (Win64) or x86 (Win32).
- In the Solution Explorer, right-click the Voice project and select Build.
- After a successful build, you should have
Voice.exe
available under\EOS-SDK\Samples\Voice\Client\Bin\Win64\Release_DX\
You can now run the sample application.
Running the Voice Client Sample App (Win64/Win32)
To run the Voice Client sample app:
- Navigate to e.g.
\EOS-SDK\Samples\Voice\Client\Bin\Win64\Release_DX\
- Run
Voice.exe
- Add
-serverport <port>
to change the server listen port. - Add
-serverurl <url>
to change the server URL.
Setup for MacOS or Linux
Setup Prerequisites
To build the Voice Client sample application on MacOS, you will need to install the following dependencies:
Building the Voice Client Sample App for MacOS or Linux
- Unzip
EOS-SDK.zip
into your location of choice. - In Terminal, navigate to
/EOS-SDK/Samples/Voice/Client/
- Open
SampleConstants.h
and update ProductId, SandboxId, DeploymentId, ClientCredentialsId, and ClientCredentialsSecret based on the values for your Test App. - Run:
./Build.sh
(or you can runBuild.command
from Finder on Mac). - Once the build successfully completes, you will have newly created files under:
/EOS-SDK/Samples/Voice/Client/Build/
You are now ready to run the sample application.
Running the Voice Client Sample App (MacOS or Linux)
To open the sample app:
- Navigate to
/EOS-SDK/Samples/Voice/Client/
- Run:
./Run.sh
(or you can runRun.command
from Finder on Mac). - Add
-serverport <port>
to change the server port. - Add
-serverurl <url>
to change the server URL.
Using the Voice Client Sample App
To log in with the Developer Authentication Tool, select the Dev Auth option and choose Log In. Once you have logged in, the Voice Client sample app includes the following options:
JOIN
Click on JOIN to start the join room process. A request will be made via the Server application to get a join room token which will then be used to join the room.
Since there are no other players in the current room a new room will be created and you will be added to the room. The room ID will be shown in the “Room:” box and the “ROOM MEMBERS” table will be updated to show you added to the room:
LEAVE
Use LEAVE room to leave the current room you are currently a member of.
MUTE
MUTE is available only for the local user and it can be used to mute your audio. When your audio is muted you will see the audio status icon change to a red color as shown below:
OWNER-ONLY
If you are the owner of the room you will have the option of muting another user or kicking them from the current room:
REMOTE MUTE
Click REMOTE MUTE to mute that user.
KICK
Click KICK to kick that user from the current room, they will not be able to rejoin unless a new room join token is requested and granted.
CHAT
Click CHAT next to a friend’s name in the friends list and you will be added to their room to allow you to chat with them.
You can also join the same room as another player who is not your friend using the JOIN console command.
AUDIO DEVICES
You can change the output and input audio devices using the dropdowns in the SETUP dialog:
SPEAKING STATUS
When a user is speaking the audio status icon will change to a green color and a full speaker:
Console Commands
JOIN
- Usage: “JOIN ROOM_NAME”.
- Starts the join room process for the local user.
- If
ROOM_NAME
is supplied that room will be joined if allowed. - If
ROOM_NAME
is not supplied a new room will be created and joined.
LEAVE
- Usage: “LEAVE”
- The local user will leave the current room.
KICK
- Usage: “KICK USER_ID”.
- Kicks a user from the current room.
- Will do nothing if you are not the room owner.
USER_ID
is a ProductUserId.
REMOTEMUTE
- Usage: “REMOTEMUTE USER_ID MUTE”.
- Sets remote mute state for a user.
- Will do nothing if you are not the room owner.
USER_ID
is a ProductUserId.- MUTE is
1
to mute and0
to unmute.
Voice Server
Setup for Windows 32/64-bit
This section covers building and running the Voice Server sample app for both 32-bit and 64-bit Windows operating systems.
Building the Voice Server Sample App for Win64/Win32
- Unzip
EOS-SDK.zip
into your location of choice. - Navigate to
\EOS-SDK\Samples\
. - Double-click
Samples.sln
. Visual Studio will open with it in the Solution Explorer. - Set the StartUp Project to VoiceServer.
- Open
SampleConstants.h
and update ProductId, SandboxId, DeploymentId, ClientCredentialsId, and ClientCredentialsSecret based on the values for your Test App. - Select the solution configuration. Use either
Release
orDebug
. - Select the solution platform: x64 (Win64) or x86 (Win32).
- In the Solution Explorer, right-click the VoiceServer project and select Build.
- After a successful build, you should have
VoiceServer.exe
available under\EOS-SDK\Samples\Voice\Server\Bin\Win64\Release\
You can now run the sample application.
Running the Voice Server Sample App (Win64/Win32)
To run the Voice Server sample app:
- Navigate to e.g.
\EOS-SDK\Samples\Voice\Server\Bin\Win64\Release\
- Run
VoiceServer.exe
- Add
-voiceserverport <port>
to change the server listen port. - Add
-voiceserverurl <url>
to change the server URL.
Setup for MacOS or Linux
Setup Prerequisites
To build the Voice Server sample application on MacOS, you will need to install the following dependencies:
- cmake
- gcc (through Command Line Tools for Xcode for Mac)
Building the Voice Client Sample App for MacOS or Linux
- Unzip
EOS-SDK.zip
into your location of choice. - In Terminal, navigate to
/EOS-SDK/Samples/Voice/Server/
- Open
SampleConstants.h
and update ProductId, SandboxId, DeploymentId, ClientCredentialsId, and ClientCredentialsSecret based on the values for your Test App. - Run:
./Build.sh
(or you can runBuild.command
from Finder on Mac). - Once the build successfully completes, you will have newly created files under:
/EOS-SDK/Samples/Voice/Server/Build/
You are now ready to run the sample application.
Running the Voice Server Sample App (MacOS)
To open the sample app:
- Navigate to
/EOS-SDK/Samples/Voice/Server/
- Run:
./Run.sh
(or you can runRun.command
from Finder on Mac). - Add
-voiceserverport <port>
to change the server listen port. - Add
-voiceserverurl <url>
to change the server URL.
Using the Voice Server Sample App
The Voice Server is a console-based application so there are no GUI elements, debug text will be printed to the console and to the debug log file (default: DebugOutput.log
). Errors will be printed out as red text and warnings as yellow text.
Once the Voice Server application has been started it can be left running and will process requests from multiple clients.
Use Ctrl+C
to stop the Server application.