Skip to content

Commit

Permalink
Merge pull request #117 from Itokoyamato/feat-websocket-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Thuillier authored Jul 3, 2020
2 parents 0595368 + 6b67bea commit 51fce98
Show file tree
Hide file tree
Showing 32 changed files with 3,214 additions and 5,469 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "ts3_plugin/deps/teamspeak-plugin-radiofx"]
path = ts3_plugin/deps/teamspeak-plugin-radiofx
url = https://github.com/Itokoyamato/teamspeak-plugin-radiofx
[submodule "ts3_plugin/deps/cpp-httplib"]
path = ts3_plugin/deps/cpp-httplib
url = https://github.com/yhirose/cpp-httplib
6 changes: 3 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
On screen displays of TokoVOIP and copyrights must remain visible and readable.
You are allowed however to change their position and design.
On screen displays of TokoVOIP watermark must remain visible and readable.
You are allowed however to change their position and design.
For the rest, the following applies:

MIT License

Copyright (c) 2019 Itokoyamato
Copyright (c) 2020 Itokoyamato

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
148 changes: 104 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,115 @@
# TokoVoip
TokoVoip is a TeamSpeak plugin used along a FiveM script to add a custom proximity chat and radio system to [FiveM](https://fivem.net/)
# Introduction: TokoVOIP
TokoVOIP is a TeamSpeak plugin used along a FiveM script to add a custom proximity chat and radio system to [FiveM](https://fivem.net/)

It includes radio effects thanks to the integration of the [RadioFX](https://www.myteamspeak.com/addons/f2e04859-d0db-489b-a781-19c2fab29def) plugin
It includes radio effects thanks to the integration of the [RadioFX](https://www.myteamspeak.com/addons/f2e04859-d0db-489b-a781-19c2fab29def) plugin

The TS3 plugin does not require any extra setting up, you just have to install it

The tokovoip_script must be running on the server with the right configuration

A documentation for the FiveM script is available [here](fivem_script)

Downloads are available [here](https://github.com/Itokoyamato/TokoVOIP_TS3/releases)

This system was originally developed for **Revolution RP** by https://rmog.us, check it out for some FiveM RP ;)
Downloads are available on the [releases](https://github.com/Itokoyamato/TokoVOIP_TS3/releases) page

If you like TokoVOIP, give it a star ! It'd be much appreciated <3

If you're feeling generous
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H2UXEZBF5KQBL&source=url)

# Terms and conditions
I require only the following to anyone that plan on using this system: to leave the copyrights included as is, and not alter the displays of the TokoVOIP name in any other way than changing their position on screen.

For the rest, refer to the [license](LICENSE.md)
You can support my work:
[![Patreon](https://img.shields.io/badge/Become%20a-patron-orange)](https://www.patreon.com/Itokoyamato)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H2UXEZBF5KQBL&source=url)

# Table of Contents
- [Introduction: TokoVOIP](#introduction-tokovoip)
- [Table of Contents](#table-of-contents)
- [Setting up TokoVOIP](#setting-up-tokovoip)
- [(players) Setting up the ts3-plugin](#players-setting-up-the-ts3-plugin)
- [(servers) Setting up the ws-server](#servers-setting-up-the-ws-server)
- [(servers) Setting up the fivem-script](#servers-setting-up-the-fivem-script)
- [(servers) Onesync Infinity](#servers-onesync-infinity)
- [How does it work ?](#how-does-it-work-)
- [Why do I need a ws-server ?](#why-do-i-need-a-ws-server-)
- [Terms and conditions](#terms-and-conditions)
- [Contributing](#contributing)
- [Building the TS3 plugin](#building-the-ts3-plugin)
- [Packaging the TS3 plugin](#packaging-the-ts3-plugin)
- [Dependencies and sources](#dependencies-and-sources)

# Setting up TokoVOIP
You can download the ws-server, fivem-script & ts3-plugin on the [release](https://github.com/Itokoyamato/TokoVOIP_TS3/releases) page

## (players) Setting up the ts3-plugin
Every player must install Teamspeak 3 and the TokoVOIP plugin
* Install the plugin downloaded on the [release](https://github.com/Itokoyamato/TokoVOIP_TS3/releases) page
* Connect to the fivem server
* Connect to the TS3 server
* Join the right TS3 channel

The TS3 Plugin will connect only if you are already in-game
The TS3 Plugin will try to connect if you join a TS3 channel containing 'tokovoip' in it's name
You can use the buttons in `Plugins->TokoVoip` to manually connect/disconnect the TS3 Plugin
## (servers) Setting up the ws-server
* **Configure the server**
Edit [config.js](https://github.com/Itokoyamato/TokoVOIP_TS3/blob/feat-websocket-proxy/ws_server/config.js) to match your configuration. Fill the IPs using your host's public IP.
Note: **TSServer** must be an **IP**, domain names are currently not supported. Please open an issue if that's something you would like to see available

* **Run the server**
* **Running as Standalone**
It can be run as a standalone NodeJS application, on the same machine as your fivem server, or on a completely different machine

* **Running as FXServer resource**
The ws-server is compatible and can be run as a FXServer resource directly
Just start it the same way you'd start any other resource

**Running it as a standalone is recommended to decouple the potential performance issues from your FiveM server, even if it's on the same machine**

## (servers) Setting up the fivem-script
* **Configure the script**
Edit [c_config.lua](https://github.com/Itokoyamato/TokoVOIP_TS3/blob/feat-websocket-proxy/fivem_script/tokovoip_script/c_config.lua) & [s_config.lua](https://github.com/Itokoyamato/TokoVOIP_TS3/blob/feat-websocket-proxy/fivem_script/tokovoip_script/s_config.lua) to match your preference
**You must configure the [wsServer](https://github.com/Itokoyamato/TokoVOIP_TS3/blob/feat-websocket-proxy/fivem_script/tokovoip_script/c_config.lua#L20) to match the IP:PORT address of your ws-server**

A documentation for the FiveM script is available [here](fivem_script)

## (servers) Onesync Infinity
Onesync infinity is supported with TokoVOIP 1.5.0+
By default, Teamspeak servers silence everyone when more than 100 users are in a channel
Make sure your teamspeak server is configured properly:
* Right click your teamspeak server
* Press `Edit virtual server`
* Press `more`
* Open tab `Misc`
* Change the value of `Min clients in channel before silence`

# How does it work ?
TS3 has an extensive and accessible API that allows the manipulation of the local clients. The issue was to access this API via FiveM, and allow a script to pass data to TS3
The system is based on websockets
In-game data is sent through websockets to the TS3 plugin
FiveM blocks websockets running on the local network, we must use a remote ws-server

FiveM scripts run in a fairly contained sandbox, to the exception of one part: `NUI`
TS3 has no way to know on which fivem server you are currently on locally, a handshake system is required
A master server is used to register handshakes
That is it's only purpose, everything else is run on your own self-hosted ws-server and fivem-script

With `NUI`, we have access to a full browser, which opens a lot of possibilities
One of them: websockets
* Phase 1 - Handshake:
* fivem-script -> ws-server -> register for handshake (master server)
* ts3-plugin -> look for handshake (master server) -> ws-server

The TS3 plugin runs a local websocket server, to which the FiveM script connects to via javascript.
Once the fivem websocket & ts3 websocket successfully handshaked, the master server is not used anymore

The lua script handles all the processing of positions, volume, muting, enabling/disabling radio effects
and then sends it to NUI as JSON,
following that, NUI simply sends the data to the TS3 plugin via websockets over the local network.
* Phase 2 - Communicate:
* fivem-script -> ws-server -> ts3-plugin
* fivem-script <- ws-server <- ts3-plugin

To be completely honest, I have never refactored the code since my very first prototypes
Ideally, I would like to build the system in a way to allow direct access to TS3's API in the lua script itself (with limitations of course)
But that never happened
It works, and that's enough for now
# Why do I need a ws-server ?
Read the following:
- [How does it work ?](#how-does-it-work-?)
- [TokoVOIP 1.5.0](https://github.com/Itokoyamato/TokoVOIP_TS3/pull/117)

# Terms and conditions
A 'TokoVOIP' watermark must be visible on screen. You can move it, change it's design however you like.
Just keep one somewhere. Thanks
For the rest, refer to the [license](LICENSE.md)

# Contributing
I am open to pull requests, feel free to build upon my work and improve it
I am open to pull requests, feel free to build upon my work and improve it
Mind you, this is my only project done in C++ and have only done low level C projects, so I am certain a lot of improvements can be made

# Building the TS3 plugin
## Building the TS3 plugin

You will need the following installed:
- [Visual Studio IDE](https://visualstudio.microsoft.com/vs/)
- [Qt 5.6.0](https://download.qt.io/archive/qt/5.6/5.6.0/)
- [Qt 5.12.7](https://download.qt.io/archive/qt/5.12.7/5.12.7/)
- [CMake](https://cmake.org/)

Clone the repo and don't forget to initialize the submodules:
Expand All @@ -62,19 +121,19 @@ Then move to the `ts3_plugin` folder, and generate the Visual Studio solution: (
```
mkdir build32
cd build32
cmake -G "Visual Studio 15 2017" -DCMAKE_PREFIX_PATH="<PATH_TO>/Qt/5.6/msvc2015" ..
cmake -G "Visual Studio 15 2017" -DCMAKE_PREFIX_PATH="<PATH_TO>/Qt/5.12.7/msvc2017" ..
cd ..
mkdir build64
cd build64
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH="<PATH_TO>/Qt/5.6/msvc2015_64" ..
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH="<PATH_TO>/Qt/5.12.7/msvc2017_64" ..
```

The visual studio solutions are available in their platform specific folders.
You're ready to go !

# Packaging the TS3 plugin
## Packaging the TS3 plugin

Making a TS3 plugin package is very easy, you can use the template in `ts3_package` if you want.
Making a TS3 plugin package is very easy, you can use the template in `ts3_package` if you want.
You will need:
- `package.ini` file which gives some info about the plugin
- `.dll` files in a `plugin` folder
Expand All @@ -89,18 +148,19 @@ Archive tree example:
```
.
+-- package.ini
+-- plugin
| +-- assets
| +-- img1.png
| +-- img2.png
+-- plugins
| +-- tokovoip
| +-- walkie_talkie16.png
| +-- mic_click_off.wav
| +-- mic_click_on.wav
| +-- plugin_win32.dll
| +-- plugin_win64.dll
```

# Dependencies and sources

- [RadioFX](https://github.com/thorwe/teamspeak-plugin-radiofx) by Thorwe
- [Simple-Web-Server](https://gitlab.com/eidheim/Simple-Web-Server) by eidheim
- [Simple-WebSocket-Server](https://gitlab.com/eidheim/Simple-WebSocket-Server) by eidheim
- [JSON for Modern C++](https://github.com/nlohmann/json.git) by nlohmann
- [CURL](https://github.com/curl/curl)
- [cpp-httplib](https://github.com/yhirose/cpp-httplib) by yhirose
- [Task Force Arma 3 Radio](https://github.com/michail-nikolaev/task-force-arma-3-radio) by michail-nikolaev for the base concept and helping in figuring out a lot of TS3's stuff
9 changes: 5 additions & 4 deletions fivem_script/tokovoip_script/c_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TokoVoipConfig = {
refreshRate = 100, -- Rate at which the data is sent to the TSPlugin
networkRefreshRate = 2000, -- Rate at which the network data is updated/reset on the local ped
playerListRefreshRate = 5000, -- Rate at which the playerList is updated
minVersion = "1.2.4", -- Version of the TS plugin required to play on the server
minVersion = "1.5.0", -- Version of the TS plugin required to play on the server

distance = {
15, -- Normal speech distance in gta distance units
Expand All @@ -17,7 +17,8 @@ TokoVoipConfig = {
radioClickMaxChannel = 100, -- Set the max amount of radio channels that will have local radio clicks enabled
radioAnim = true, -- Enable or disable the radio animation
radioEnabled = true, -- Enable or disable using the radio

wsServer = "ip:port", -- Address of the websocket server

plugin_data = {
-- TeamSpeak channel name used by the voip
-- If the TSChannelWait is enabled, players who are currently in TSChannelWait will be automatically moved
Expand All @@ -30,9 +31,9 @@ TokoVoipConfig = {
TSChannelWait = "TokoVOIP Server Waiting Room IPS DESC",

-- Blocking screen informations
TSServer = "ts.rmog.us", -- TeamSpeak server address to be displayed on blocking screen
TSServer = "ts.yourserver.com", -- TeamSpeak server address to be displayed on blocking screen
TSChannelSupport = "S1: Waiting For Support", -- TeamSpeak support channel name displayed on blocking screen
TSDownload = "[[COMMUNITY WEBSITE URL HERE]]", -- Download link displayed on blocking screen
TSDownload = "https://github.com/Itokoyamato/TokoVOIP_TS3/releases", -- Download link displayed on blocking screen
TSChannelWhitelist = { -- Black screen will not be displayed when users are in those TS channels
"Support 1",
"Support 2",
Expand Down
4 changes: 2 additions & 2 deletions fivem_script/tokovoip_script/nui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<br><br>
If you cannot join the appropriate server channel, please join <font color="#01b0f0" id="TSChannelSupport"></font> channel in teamspeak, so that a support team member can help you.
<br><br>
You can find more <font color="#f0eb01">information</font> and <font color="#f0eb01">download</font> links at: <font color="#01b0f0" id="TSDownload">http://forums.rmog.us</font>
You can find more <font color="#f0eb01">information</font> and <font color="#f0eb01">download</font> links at: <font color="#01b0f0" id="TSDownload">https://github.com/Itokoyamato/TokoVOIP_TS3/releases</font>
<br><br><br>

<div id="TSServer">
Expand All @@ -97,7 +97,7 @@
</div>
</div>
<div class="copyrights">
TokoVoip by Itokoyamato (forums.rmog.us)
TokoVoip by Itokoyamato
</div>
<div id="tokovoipInfo" class="tokovoipInfo">
</div>
Expand Down
Loading

0 comments on commit 51fce98

Please sign in to comment.