Added some scripts and live statistics

canary
WolverinDEV 2019-02-25 15:59:42 +01:00
parent 6da22ca24c
commit 9e01c84641
6 changed files with 58 additions and 11 deletions

View File

@ -21,7 +21,7 @@ function replace_tribble() {
#Building the generator
./tools/build_dtsgen.sh
if [ $? -ne 0 ]; then
if [[ $? -ne 0 ]]; then
echo "Failed to build typescript declaration generator"
exit 1
fi

25
scripts/cleanup.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "$BASEDIR/../"
# This script cleanups all generated files
function remove_if_exists() {
if [[ -f "$1" ]] || [[ -d "$1" ]]; then
echo "Deleting $1"
rm -r "$1"
fi
}
function cleanup_declarations() {
remove_if_exists shared/declarations/
remove_if_exists web/declarations/
}
function cleanup_generated_files() {
remove_if_exists shared/generated
remove_if_exists web/generated
}
cleanup_declarations
cleanup_generated_files

View File

@ -554,6 +554,8 @@ const loader_javascript = {
"js/connection/HandshakeHandler.js",
"js/connection/ServerConnection.js",
"js/stats.js",
"js/PPTListener.js",

View File

@ -40,7 +40,7 @@ namespace log {
[LogCategory.GENERAL, true],
[LogCategory.NETWORKING, true],
[LogCategory.VOICE, true],
[LogCategory.I18N, true]
[LogCategory.I18N, false]
]);
loader.register_task(loader.Stage.LOADED, {

View File

@ -272,6 +272,15 @@ function main() {
globalClient.channelTree.handle_resized();
}, 1000);
});
stats.initialize({
verbose: true,
anonymize_ip_addresses: true,
volatile_collection_only: false
});
stats.register_user_count_listener(status => {
console.log("Received user count update: %o", status);
});
}
loader.register_task(loader.Stage.LOADED, {

View File

@ -96,16 +96,14 @@ namespace stats {
export function start_connection() {
cancel_reconnect();
if(connection) {
const connection_copy = connection;
connection = undefined;
connection_copy.close(3001);
}
close_connection();
connection_state = ConnectionState.CONNECTING;
connection = new WebSocket('wss://web-stats.teaspeak.de:1774');
connection = new WebSocket('wss://web-stats.teaspeak.de:27790');
if(!connection)
connection = new WebSocket('wss://localhost:27788');
{
const connection_copy = connection;
connection.onclose = (event: CloseEvent) => {
@ -135,7 +133,7 @@ namespace stats {
console.log(LOG_PREFIX + tr("Received an error. Closing connection. Object: %o"), event);
connection.close(CloseCodes.INTERNAL_ERROR);
this.invoke_reconnect();
invoke_reconnect();
};
connection.onmessage = (event: MessageEvent) => {
@ -152,7 +150,20 @@ namespace stats {
}
}
export function close_connection() {
if(connection) {
const connection_copy = connection;
connection = undefined;
try {
connection_copy.close(3001);
} catch(_) {}
}
}
function invoke_reconnect() {
close_connection();
if(reconnect_timer) {
clearTimeout(reconnect_timer);
reconnect_timer = undefined;