Fixed some things related to the TeaSpeak client

This commit is contained in:
WolverinDEV 2019-04-15 16:58:42 +02:00
parent 5b05b0c7f2
commit 83d4164a80
6 changed files with 67 additions and 15 deletions

View file

@ -22,4 +22,8 @@ namespace forum {
export function open() {
ipc.send("teaforo-login");
}
export function logout() {
ipc.send("teaforo-logout");
}
}

View file

@ -10,8 +10,6 @@
/// <reference path="ui/frames/ControlBar.ts" />
/// <reference path="connection/ConnectionBase.ts" />
import spawnConnectModal = Modals.spawnConnectModal;
enum DisconnectReason {
HANDLER_DESTROYED,
REQUESTED,
@ -23,6 +21,8 @@ enum DisconnectReason {
CLIENT_KICKED,
CLIENT_BANNED,
HANDSHAKE_FAILED,
HANDSHAKE_TEAMSPEAK_REQUIRED,
HANDSHAKE_BANNED,
SERVER_CLOSED,
SERVER_REQUIRES_PASSWORD,
IDENTITY_TOO_LOW,
@ -407,6 +407,14 @@ class ConnectionHandler {
tr("Failed to process handshake: ") + data as string
).open();
break;
case DisconnectReason.HANDSHAKE_TEAMSPEAK_REQUIRED:
createErrorModal(
tr("Target server is a TeamSpeak server"),
MessageHelper.formatMessage(tr("The target server is a TeamSpeak 3 server!{:br:}Only TeamSpeak 3 based identities are able to connect.{:br}Please select another profile or change the identify type."))
).open();
this.sound.play(Sound.CONNECTION_DISCONNECTED);
auto_reconnect = false;
break;
case DisconnectReason.IDENTITY_TOO_LOW:
createErrorModal(
tr("Identity level is too low"),
@ -457,11 +465,18 @@ class ConnectionHandler {
}).open();
break;
case DisconnectReason.CLIENT_KICKED:
this.chat.serverChat().appendError(tr("You got kicked from the server by {0}{1}"),
createErrorModal(
tr("You've been banned"),
MessageHelper.formatMessage(tr("You've been banned from this server.{:br:}{0}"), data["extra_message"])
).open();
this.sound.play(Sound.SERVER_KICKED);
auto_reconnect = false;
break;
case DisconnectReason.HANDSHAKE_BANNED:
this.chat.serverChat().appendError(tr("You got banned from the server by {0}{1}"),
ClientEntry.chatTag(data["invokerid"], data["invokername"], data["invokeruid"]),
data["reasonmsg"] ? " (" + data["reasonmsg"] + ")" : "");
this.sound.play(Sound.SERVER_KICKED);
auto_reconnect = true;
this.sound.play(Sound.CONNECTION_BANNED); //TODO findout if it was a disconnect or a connect refuse
break;
case DisconnectReason.CLIENT_BANNED:
this.chat.serverChat().appendError(tr("You got banned from the server by {0}{1}"),

View file

@ -49,6 +49,19 @@ namespace connection {
this.handshake_handler.start_handshake();
}
on_teamspeak() {
const type = this.profile.selected_type();
if(type == profiles.identities.IdentitifyType.TEAMSPEAK)
this.handshake_finished();
else {
if(this.failed) return;
this.failed = true;
this.connection.client.handleDisconnect(DisconnectReason.HANDSHAKE_TEAMSPEAK_REQUIRED);
}
}
private handshake_failed(message: string) {
if(this.failed) return;
@ -71,7 +84,6 @@ namespace connection {
const git_version = settings.static_global("version", "unknown");
const browser_name = (navigator.browserSpecs || {})["name"] || " ";
let data = {
//TODO variables!
client_nickname: this.name,
client_platform: (browser_name ? browser_name + " " : "") + navigator.platform,
client_version: "TeaWeb " + git_version + " (" + navigator.userAgent + ")",
@ -119,6 +131,8 @@ namespace connection {
} else if(error.id == 783 || error.id == 519) {
error.extra_message = parseInt(error.extra_message) == NaN ? "8" : error.extra_message;
this.connection.client.handleDisconnect(DisconnectReason.IDENTITY_TOO_LOW, error);
} else if(error.id == 3329) {
this.connection.client.handleDisconnect(DisconnectReason.HANDSHAKE_BANNED, error);
} else {
this.connection.client.handleDisconnect(DisconnectReason.CLIENT_KICKED, error);
}

View file

@ -504,7 +504,13 @@ const loader_javascript = {
name: "javascript web",
priority: 10,
function: loader_javascript.load_scripts_debug_web
})
});
} else {
loader.register_task(loader.Stage.JAVASCRIPT, {
name: "javascript client",
priority: 10,
function: loader_javascript.load_scripts_debug_client
});
}
/* load some extends classes */
@ -618,6 +624,11 @@ const loader_javascript = {
["js/WebPPTListener.js"]
]);
},
load_scripts_debug_client: async () => {
await loader.load_scripts([
["js/teaforo.js"]
]);
},
load_release: async () => {
console.log("Load for release!");

View file

@ -222,10 +222,6 @@ namespace profiles.identities {
});
}
skip_and_initialize() {
this.trigger_success();
}
private handle_proof(json) {
if(!json[0]["digest"]) {
this.trigger_fail("server too old");

View file

@ -238,11 +238,23 @@ namespace Modals {
} else {
tag.find(".connected").hide();
}
tag.find(".button-logout").on('click', event => {
window.location.href = settings.static("forum_path") + "auth.php?type=logout";
if(native_client) {
modal.close(); /* we cant update the modal so we close it */
forum.logout();
} else {
window.location.href = settings.static("forum_path") + "auth.php?type=logout";
}
});
tag.find(".button-login").on('click', event => {
window.location.href = settings.static("forum_path") + "login.php";
if(native_client) {
modal.close(); /* we cant update the modal so we close it */
forum.open();
} else {
window.location.href = settings.static("forum_path") + "login.php";
}
});
}
}
@ -761,7 +773,7 @@ namespace Modals {
if (identity && identity.valid()) {
forum_tag.find(".connected").show();
} else {
forum_tag.find(".disconnected").show();
_tag.find(".disconnected").show();
}
} else if (selected_type == profiles.identities.IdentitifyType.TEAMSPEAK) {
console.log("Set: " + identity);
@ -930,7 +942,7 @@ namespace Modals {
});
}
{ //The forum
{ //The
const teaforo_tag = settings_tag.find(".identity-settings-teaforo");
if (native_client) {
teaforo_tag.find(".native-teaforo-login").on('click', event => {