Some small changes
parent
41876e273c
commit
1610fd9d51
|
@ -21,6 +21,7 @@ export type LocalAgent = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ClientServiceConfig {
|
export interface ClientServiceConfig {
|
||||||
|
getServiceHost() : string;
|
||||||
getSelectedLocaleUrl() : string | null;
|
getSelectedLocaleUrl() : string | null;
|
||||||
getSessionType() : ClientSessionType;
|
getSessionType() : ClientSessionType;
|
||||||
generateHostInfo() : LocalAgent;
|
generateHostInfo() : LocalAgent;
|
||||||
|
@ -51,7 +52,7 @@ export class ClientServices {
|
||||||
this.initializeLocaleId = 0;
|
this.initializeLocaleId = 0;
|
||||||
|
|
||||||
this.sessionInitialized = false;
|
this.sessionInitialized = false;
|
||||||
this.connection = new ClientServiceConnection(5000);
|
this.connection = new ClientServiceConnection(config.getServiceHost(), 5000);
|
||||||
this.connection.events.on("notify_state_changed", event => {
|
this.connection.events.on("notify_state_changed", event => {
|
||||||
if(event.newState !== "connected") {
|
if(event.newState !== "connected") {
|
||||||
if(this.sessionInitialized) {
|
if(this.sessionInitialized) {
|
||||||
|
|
|
@ -22,6 +22,8 @@ export class ClientServiceConnection {
|
||||||
readonly events: Registry<ClientServiceConnectionEvents>;
|
readonly events: Registry<ClientServiceConnectionEvents>;
|
||||||
readonly reconnectInterval: number;
|
readonly reconnectInterval: number;
|
||||||
|
|
||||||
|
private readonly serviceHost: string;
|
||||||
|
|
||||||
private reconnectTimeout: any;
|
private reconnectTimeout: any;
|
||||||
private connectionState: ConnectionState;
|
private connectionState: ConnectionState;
|
||||||
private connection: WebSocket;
|
private connection: WebSocket;
|
||||||
|
@ -29,7 +31,8 @@ export class ClientServiceConnection {
|
||||||
private pendingCommands: {[key: string]: PendingCommand} = {};
|
private pendingCommands: {[key: string]: PendingCommand} = {};
|
||||||
private notifyHandler: {[key: string]: ((event) => void)[]} = {};
|
private notifyHandler: {[key: string]: ((event) => void)[]} = {};
|
||||||
|
|
||||||
constructor(reconnectInterval: number) {
|
constructor(serviceHost: string, reconnectInterval: number) {
|
||||||
|
this.serviceHost = serviceHost;
|
||||||
this.events = new Registry<ClientServiceConnectionEvents>();
|
this.events = new Registry<ClientServiceConnectionEvents>();
|
||||||
this.reconnectInterval = reconnectInterval;
|
this.reconnectInterval = reconnectInterval;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +62,7 @@ export class ClientServiceConnection {
|
||||||
|
|
||||||
this.setState("connecting");
|
this.setState("connecting");
|
||||||
|
|
||||||
let address;
|
this.connection = new WebSocket(`wss://${this.serviceHost}/ws-api/v${kApiVersion}`);
|
||||||
address = "client-services.teaspeak.de:27791";
|
|
||||||
address = "localhost:1244";
|
|
||||||
//address = "192.168.40.135:1244";
|
|
||||||
|
|
||||||
this.connection = new WebSocket(`wss://${address}/ws-api/v${kApiVersion}`);
|
|
||||||
this.connection.onclose = event => {
|
this.connection.onclose = event => {
|
||||||
clientServiceLogger.logTrace("Lost connection to statistics server (Connection closed). Reason: %s", event.reason ? `${event.reason} (${event.code})` : event.code);
|
clientServiceLogger.logTrace("Lost connection to statistics server (Connection closed). Reason: %s", event.reason ? `${event.reason} (${event.code})` : event.code);
|
||||||
this.handleConnectionLost();
|
this.handleConnectionLost();
|
||||||
|
@ -214,7 +212,7 @@ export class ClientServiceConnection {
|
||||||
const unregisterHandler = () => {
|
const unregisterHandler = () => {
|
||||||
const index = handlers.indexOf(handler);
|
const index = handlers.indexOf(handler);
|
||||||
if(index !== -1) {
|
if(index !== -1) {
|
||||||
handlers.remove(handler);
|
handlers.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class GeoLocationProvider {
|
||||||
|
|
||||||
this.cachedInfo = info.info;
|
this.cachedInfo = info.info;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
clientServiceLogger.logTrace(tr("Failed to load geo resolve cache: %o"), error);
|
clientServiceLogger.logTrace(tr("Failed to load geo resolve cache:\n%o"), error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class GeoLocationProvider {
|
||||||
} as GeoLocationCache));
|
} as GeoLocationCache));
|
||||||
return info;
|
return info;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
clientServiceLogger.logTrace(tr("Geo resolver %s failed: %o. Trying next one."), resolver.name(), error);
|
clientServiceLogger.logTrace(tr("Geo resolver %s failed. Trying next one:\n%o"), resolver.name(), error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue