<eg-staff-banner bannerText="Sandbox" i18n-bannerText>
</eg-staff-banner>
+<div class="row mt-2 mb-2">
+ <div class="col-lg-2">
+ <button (click)="testWebsockets()" class="btn btn-success">
+ Test Parallel Websockets
+ </button>
+ </div>
+ <div class="col-lg-2">
+ Sent = {{wsSent}}, received = {{wsReceived}}
+ </div>
+ <div class="col-lg-8">
+ <eg-progress-inline [max]="wsSendCount" value="0" #wsProgress></eg-progress-inline>
+ </div>
+</div>
+
<eg-title
i18n-prefix i18n-suffix
prefix=":) {{dynamicTitleText}}"
import {timer as observableTimer, Observable, of} from 'rxjs';
import {Component, OnInit, ViewChild, Input, TemplateRef} from '@angular/core';
import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
+import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component';
import {ToastService} from '@eg/share/toast/toast.service';
import {StringService} from '@eg/share/string/string.service';
import {map, take} from 'rxjs/operators';
})
export class SandboxComponent implements OnInit {
+ @ViewChild('wsProgress') private wsDialog: ProgressInlineComponent;
+
@ViewChild('progressDialog', { static: true })
private progressDialog: ProgressDialogComponent;
@ViewChild('penaltyDialog', {static: false}) penaltyDialog;
+ wsSendCount = 500;
+ wsSent = 0;
+ wsReceived = 0;
// @ViewChild('helloStr') private helloStr: StringComponent;
this.penaltyDialog.open()
.subscribe(val => console.log('penalty value', val));
}
+
+ testWebsockets() {
+ this.wsSent = 0;
+ this.wsReceived = 0;
+ this.wsDialog.update({value: 0});
+
+ while (this.wsSent < this.wsSendCount) {
+ this.wsSent++;
+
+ // Firing requests in parallel
+ this.pcrud.retrieve('aou', 1).toPromise().then(o => {
+ this.wsReceived++;
+ this.wsDialog.increment();
+ });
+ }
+ }
}