Twitch login, TTS Login, and basic policies ui.

This commit is contained in:
Tom
2024-10-17 08:48:15 +00:00
parent f2133bbc0e
commit 89d944cd6e
48 changed files with 1443 additions and 504 deletions

View File

@ -0,0 +1,52 @@
import { Component, OnInit, Injectable } from '@angular/core';
import { webSocket, WebSocketSubject } from 'rxjs/webSocket';
import { catchError, tap, switchAll } from 'rxjs/operators';
import { EMPTY, Observer, Subject } from 'rxjs';
import { environment } from '../environments/environment';
@Injectable({
providedIn: 'root'
})
export class HermesSocketService implements OnInit {
private WS_ENDPOINT = environment.WSS_ENDPOINT;
private socket: WebSocketSubject<any> | undefined = undefined
constructor() { }
ngOnInit(): void {
}
public connect(): void {
if (!this.socket || this.socket.closed) {
this.socket = this.getNewWebSocket();
}
}
private getNewWebSocket() {
return webSocket({
url: WS_ENDPOINT
});
}
public sendMessage(msg: any) {
if (!this.socket || this.socket.closed)
return
this.socket.next(msg);
}
public subscribe(subscriptions: any) {
if (!this.socket || this.socket.closed)
return
return this.socket.subscribe(subscriptions);
}
public close() {
if (!this.socket || this.socket.closed)
return
this.socket.complete();
}
}