mirror of
https://gitlab.com/openlp/web-remote.git
synced 2024-12-22 11:32:47 +00:00
Merge branch 'websockets' into 'master'
Update the State Management code See merge request openlp/web-remote!21
This commit is contained in:
commit
7ad0d39871
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@openlp/web-remote",
|
"name": "@openlp/web-remote",
|
||||||
"version": "0.9.3",
|
"version": "0.9.4",
|
||||||
"description": "The web remote for OpenLP, written in Angular",
|
"description": "The web remote for OpenLP, written in Angular",
|
||||||
"keywords": ["OpenLP", "Angular", "Remote"],
|
"keywords": ["OpenLP", "Angular", "Remote"],
|
||||||
"homepage": "https://openlp.org/",
|
"homepage": "https://openlp.org/",
|
||||||
|
@ -12,7 +12,7 @@ export class MainViewComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.updateImage();
|
this.updateImage();
|
||||||
this.openlpService.liveChanged$.subscribe(item => this.updateImage());
|
this.openlpService.stateChanged$.subscribe(item => this.updateImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateImage(): void {
|
updateImage(): void {
|
||||||
|
@ -36,7 +36,6 @@ const httpOptions = {
|
|||||||
export class OpenLPService {
|
export class OpenLPService {
|
||||||
private apiURL: string;
|
private apiURL: string;
|
||||||
public stateChanged$: EventEmitter<State>;
|
public stateChanged$: EventEmitter<State>;
|
||||||
public liveChanged$: EventEmitter<State>;
|
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
const host = window.location.hostname;
|
const host = window.location.hostname;
|
||||||
@ -51,7 +50,7 @@ export class OpenLPService {
|
|||||||
|
|
||||||
this.stateChanged$ = new EventEmitter<State>();
|
this.stateChanged$ = new EventEmitter<State>();
|
||||||
this.retrieveSystemInformation().subscribe(info => {
|
this.retrieveSystemInformation().subscribe(info => {
|
||||||
const ws = new WebSocket(`ws://${host}:${info.websocket_port}/state`);
|
const ws = new WebSocket(`ws://${host}:${info.websocket_port}`);
|
||||||
ws.onmessage = (event) => {
|
ws.onmessage = (event) => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
@ -61,18 +60,6 @@ export class OpenLPService {
|
|||||||
reader.readAsText(event.data);
|
reader.readAsText(event.data);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
this.liveChanged$ = new EventEmitter<State>();
|
|
||||||
this.retrieveSystemInformation().subscribe(info => {
|
|
||||||
const ws = new WebSocket(`ws://${host}:${info.websocket_port}/live_changed`);
|
|
||||||
ws.onmessage = (event) => {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = () => {
|
|
||||||
const state = deserialize(JSON.parse(reader.result as string).results, State);
|
|
||||||
this.liveChanged$.emit(state);
|
|
||||||
};
|
|
||||||
reader.readAsText(event.data);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAuthToken(token: string): void {
|
setAuthToken(token: string): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user