send external scans to app
This commit is contained in:
parent
3e47d3ebf6
commit
304ae1147e
7 changed files with 219 additions and 5 deletions
|
@ -14,9 +14,10 @@ export abstract class SocketManager {
|
|||
connection: SocketConnectionTypes,
|
||||
restoreAfterDisconnect: boolean = false
|
||||
): Socket {
|
||||
console.log("establish");
|
||||
const existingSocket = this.connections.get(connection);
|
||||
if (existingSocket !== undefined && existingSocket.connected) return existingSocket!;
|
||||
|
||||
console.log("create");
|
||||
existingSocket?.removeAllListeners();
|
||||
|
||||
const notificationStore = useNotificationStore();
|
||||
|
@ -32,7 +33,7 @@ export abstract class SocketManager {
|
|||
this.socketHandleError(connection, err, true);
|
||||
});
|
||||
socket.on("disconnect", () => {
|
||||
if (restoreAfterDisconnect) this.establishConnection(connection);
|
||||
if (restoreAfterDisconnect) this.establishConnection(connection, restoreAfterDisconnect);
|
||||
else notificationStore.push("Socket", `Verbindung getrennt`, "info");
|
||||
});
|
||||
socket.on("warning", (msg: string) => {
|
||||
|
@ -56,6 +57,7 @@ export abstract class SocketManager {
|
|||
public static closeConnection(connection: SocketConnectionTypes) {
|
||||
let socket = this.connections.get(connection);
|
||||
if (socket) {
|
||||
socket.removeAllListeners();
|
||||
socket.disconnect();
|
||||
this.connections.delete(connection);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue