1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import { Client } from '../src/client';
-
- const url = 'ws://127.0.0.1:8081';
- const client = new Client(
- url,
- new (class {
- public onOpen(): void {
- client.ping(
- {},
- new (class {
- public onStart(): void {
- console.log('start ping');
- }
-
- public onSuccess(data: string): void {
- console.log('ping successful:', data);
- }
-
- public onError(code: number, message: string): void {
- console.log('ping error:', message);
- }
-
- public onEnd(): void {
- console.log('end ping');
- }
- })(),
- );
-
- client.syncSend(
- '/v1/healthy',
- {},
- new (class {
- public onStart(): void {
- console.log('start request');
- }
-
- public onSuccess(data: string): void {
- console.log('request successful:', data);
- }
-
- public onError(code: number, message: string): void {
- console.log('request error:', message);
- }
-
- public onEnd(): void {
- console.log('end request');
- }
- })(),
- );
- }
-
- public onClose(ev: Event): void {
- console.log('connection error', ev);
- console.log(ev);
- }
-
- public onError(): void {
- console.log('close connection');
- }
- })(),
- );
|