connect on startup
This commit is contained in:
parent
6128f826b1
commit
741b303348
@ -1,9 +1,11 @@
|
||||
import Services from './services';
|
||||
import IndexedDB from './database'
|
||||
import { WebSocketClient } from './websockets';
|
||||
|
||||
const wsurl = "ws://127.0.0.1:8090";
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
try {
|
||||
const services = await Services.getInstance();
|
||||
await services.addWebsocketConnection(wsurl);
|
||||
|
||||
if ((await services.isNewUser())) {
|
||||
await services.displayCreateId();
|
||||
|
@ -6,6 +6,7 @@ class Services {
|
||||
private static instance: Services;
|
||||
private sdkClient: any;
|
||||
private current_process: string | null = null;
|
||||
private websocketConnection: WebSocketClient[] = [];
|
||||
|
||||
// Private constructor to prevent direct instantiation from outside
|
||||
private constructor() {}
|
||||
@ -44,6 +45,14 @@ class Services {
|
||||
|
||||
// }
|
||||
|
||||
public async addWebsocketConnection(url: string): Promise<void> {
|
||||
const services = await Services.getInstance();
|
||||
const newClient = new WebSocketClient(url, services);
|
||||
if (!services.websocketConnection.includes(newClient)) {
|
||||
services.websocketConnection.push(newClient);
|
||||
}
|
||||
}
|
||||
|
||||
public async isNewUser(): Promise<boolean> {
|
||||
let isNew = false;
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user