Fixed some native client related bugs

This commit is contained in:
WolverinDEV 2020-04-11 11:43:41 +02:00
parent 323b4e7006
commit 10a5ccbff3
7 changed files with 26 additions and 31 deletions

View file

@ -347,6 +347,7 @@ export class ConnectionHandler {
@EventHandler<ConnectionEvents>("notify_connection_state_changed") @EventHandler<ConnectionEvents>("notify_connection_state_changed")
private handleConnectionConnected(event: ConnectionEvents["notify_connection_state_changed"]) { private handleConnectionConnected(event: ConnectionEvents["notify_connection_state_changed"]) {
if(event.new_state !== ConnectionState.CONNECTED) return; if(event.new_state !== ConnectionState.CONNECTED) return;
log.info(LogCategory.CLIENT, tr("Client connected")); log.info(LogCategory.CLIENT, tr("Client connected"));
this.log.log(server_log.Type.CONNECTION_CONNECTED, { this.log.log(server_log.Type.CONNECTION_CONNECTED, {
own_client: this.getClient().log_data() own_client: this.getClient().log_data()
@ -667,6 +668,7 @@ export class ConnectionHandler {
} }
private on_connection_state_changed(old_state: ConnectionState, new_state: ConnectionState) { private on_connection_state_changed(old_state: ConnectionState, new_state: ConnectionState) {
console.log("From %s to %s", ConnectionState[old_state], ConnectionState[new_state]);
this.event_registry.fire("notify_connection_state_changed", { this.event_registry.fire("notify_connection_state_changed", {
old_state: old_state, old_state: old_state,
new_state: new_state new_state: new_state

View file

@ -428,7 +428,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler {
tree.moveClient(client, channel); tree.moveClient(client, channel);
} }
if(this.connection_handler.client_status.queries_visible || client.properties.client_type != ClientType.CLIENT_QUERY) { if(this.connection_handler.areQueriesShown() || client.properties.client_type != ClientType.CLIENT_QUERY) {
const own_channel = this.connection.client.getClient().currentChannel(); const own_channel = this.connection.client.getClient().currentChannel();
this.connection_handler.log.log(server_log.Type.CLIENT_VIEW_ENTER, { this.connection_handler.log.log(server_log.Type.CLIENT_VIEW_ENTER, {
channel_from: old_channel ? old_channel.log_data() : undefined, channel_from: old_channel ? old_channel.log_data() : undefined,
@ -531,7 +531,7 @@ export class ConnectionCommandHandler extends AbstractCommandHandler {
} }
if(this.connection_handler.client_status.queries_visible || client.properties.client_type != ClientType.CLIENT_QUERY) { if(this.connection_handler.areQueriesShown() || client.properties.client_type != ClientType.CLIENT_QUERY) {
const own_channel = this.connection.client.getClient().currentChannel(); const own_channel = this.connection.client.getClient().currentChannel();
let channel_from = tree.findChannel(entry["cfid"]); let channel_from = tree.findChannel(entry["cfid"]);
let channel_to = tree.findChannel(entry["ctid"]); let channel_to = tree.findChannel(entry["ctid"]);

View file

@ -22,6 +22,7 @@ export type ConnectionStateListener = (old_state: ConnectionState, new_state: Co
export abstract class AbstractServerConnection { export abstract class AbstractServerConnection {
readonly client: ConnectionHandler; readonly client: ConnectionHandler;
readonly command_helper: CommandHelper; readonly command_helper: CommandHelper;
protected connection_state_: ConnectionState = ConnectionState.UNCONNECTED;
protected constructor(client: ConnectionHandler) { protected constructor(client: ConnectionHandler) {
this.client = client; this.client = client;
@ -48,7 +49,12 @@ export abstract class AbstractServerConnection {
abstract handshake_handler() : HandshakeHandler; /* only valid when connected */ abstract handshake_handler() : HandshakeHandler; /* only valid when connected */
//FIXME: Remove this this is currently only some kind of hack //FIXME: Remove this this is currently only some kind of hack
abstract updateConnectionState(state: ConnectionState); updateConnectionState(state: ConnectionState) {
const old_state = this.connection_state_;
this.connection_state_ = state;
if(this.onconnectionstatechanged)
this.onconnectionstatechanged(old_state, state);
}
abstract ping() : { abstract ping() : {
native: number, native: number,

View file

@ -76,12 +76,11 @@ export class HandshakeHandler {
private handshake_finished(version?: string) { private handshake_finished(version?: string) {
const _native = window["native"]; const _native = window["native"];
if(native_client && _native && _native.client_version && !version) { if(__build.target === "client" && _native.client_version && !version) {
_native.client_version() _native.client_version()
.then( this.handshake_finished.bind(this)) .then( this.handshake_finished.bind(this))
.catch(error => { .catch(error => {
console.error(tr("Failed to get version:")); console.error(tr("Failed to get version: %o"), error);
console.error(error);
this.handshake_finished("?.?.?"); this.handshake_finished("?.?.?");
}); });
return; return;
@ -102,19 +101,16 @@ export class HandshakeHandler {
client_server_password: this.parameters.password ? this.parameters.password.password : undefined, client_server_password: this.parameters.password ? this.parameters.password.password : undefined,
client_browser_engine: navigator.product, client_browser_engine: navigator.product,
client_input_hardware: this.connection.client.client_status.input_hardware, client_input_hardware: this.connection.client.client_status.input_hardware, //FIXME: No direct access to that state!
client_output_hardware: false, client_output_hardware: false,
client_input_muted: this.connection.client.client_status.input_muted, client_input_muted: this.connection.client.client_status.input_muted, //FIXME: No direct access to that state!
client_output_muted: this.connection.client.client_status.output_muted, client_output_muted: this.connection.client.client_status.output_muted, //FIXME: No direct access to that state!
}; };
//0.0.1 [Build: 1549713549] Linux 7XvKmrk7uid2ixHFeERGqcC8vupeQqDypLtw2lY9slDNPojEv//F47UaDLG+TmVk4r6S0TseIKefzBpiRtLDAQ==
if(version) { if(version) {
data.client_version = "TeaClient "; data.client_version = "TeaClient " + version;
data.client_version += " " + version;
const os = require("os"); const os = __non_webpack_require__("os");
const arch_mapping = { const arch_mapping = {
"x32": "32bit", "x32": "32bit",
"x64": "64bit" "x64": "64bit"
@ -129,10 +125,8 @@ export class HandshakeHandler {
data.client_platform = (os_mapping[os.platform()] || os.platform()); data.client_platform = (os_mapping[os.platform()] || os.platform());
} }
/* required to keep compatibility */ if(this.profile.selected_type() === IdentitifyType.TEAMSPEAK)
if(this.profile.selected_type() === IdentitifyType.TEAMSPEAK) {
data["client_key_offset"] = (this.profile.selected_identity() as TeaSpeakIdentity).hash_number; data["client_key_offset"] = (this.profile.selected_identity() as TeaSpeakIdentity).hash_number;
}
this.connection.send_command("clientinit", data).catch(error => { this.connection.send_command("clientinit", data).catch(error => {
if(error instanceof CommandResult) { if(error instanceof CommandResult) {

View file

@ -78,8 +78,10 @@ declare global {
hljs: HighlightJS; hljs: HighlightJS;
remarkable: any; remarkable: any;
require(id: string): any;
readonly require: typeof require;
} }
const __non_webpack_require__: typeof require;
interface Navigator { interface Navigator {
browserSpecs: { browserSpecs: {

View file

@ -42,15 +42,15 @@ export class ChannelTree {
private _listener_document_click; private _listener_document_click;
private _listener_document_key; private _listener_document_key;
private _scroll_bar: SimpleBar; private _scroll_bar/*: SimpleBar*/;
constructor(client) { constructor(client) {
this.client = client; this.client = client;
this._tag_container = $.spawn("div").addClass("channel-tree-container"); this._tag_container = $.spawn("div").addClass("channel-tree-container");
this._tag_entries = $.spawn("div").addClass("channel-tree"); this._tag_entries = $.spawn("div").addClass("channel-tree");
if('SimpleBar' in window) /* for MSEdge, and may consider Firefox? */ //if('SimpleBar' in window) /* for MSEdge, and may consider Firefox? */
this._scroll_bar = new SimpleBar(this._tag_container[0]); // this._scroll_bar = new SimpleBar(this._tag_container[0]);
this.client_mover = new ClientMover(this); this.client_mover = new ClientMover(this);
this.reset(); this.reset();
@ -131,7 +131,7 @@ export class ChannelTree {
e.recalculate_repetitive_name(); e.recalculate_repetitive_name();
e.reorderClients(); e.reorderClients();
}); });
this._scroll_bar.recalculate(); this._scroll_bar?.recalculate();
} }
showContextMenu(x: number, y: number, on_close: () => void = undefined) { showContextMenu(x: number, y: number, on_close: () => void = undefined) {

View file

@ -28,8 +28,6 @@ class ReturnListener<T> {
} }
export class ServerConnection extends AbstractServerConnection { export class ServerConnection extends AbstractServerConnection {
_connectionState: ConnectionState = ConnectionState.UNCONNECTED;
private _remote_address: ServerAddress; private _remote_address: ServerAddress;
private _handshakeHandler: HandshakeHandler; private _handshakeHandler: HandshakeHandler;
@ -297,13 +295,6 @@ export class ServerConnection extends AbstractServerConnection {
this._handshakeHandler.startHandshake(); this._handshakeHandler.startHandshake();
} }
updateConnectionState(state: ConnectionState) {
const old_state = this._connectionState;
this._connectionState = state;
if(this._connection_state_listener)
this._connection_state_listener(old_state, state);
}
async disconnect(reason?: string) : Promise<void> { async disconnect(reason?: string) : Promise<void> {
this.updateConnectionState(ConnectionState.DISCONNECTING); this.updateConnectionState(ConnectionState.DISCONNECTING);
try { try {