31 lines
725 B
TypeScript
31 lines
725 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import {
|
|
Client,
|
|
ClientNotificationCodec,
|
|
WebSocketClientRWC,
|
|
WebSocketClientRWCConfig,
|
|
JSONClientCodec
|
|
} from '@overflow/rpc-js';
|
|
import { Subscription } from 'rxjs';
|
|
|
|
const config: WebSocketClientRWCConfig = {
|
|
url: 'ws://localhost:60000/scanner'
|
|
};
|
|
const rwc = new WebSocketClientRWC(config);
|
|
const codec = new JSONClientCodec();
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ProbeService extends Client {
|
|
private notiSubscription: Subscription;
|
|
|
|
public constructor() {
|
|
super(codec, rwc);
|
|
this.notiSubscription = this.notification()
|
|
.subscribe((notiCodec: ClientNotificationCodec) => {
|
|
console.log(notiCodec.method());
|
|
});
|
|
}
|
|
}
|