Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected onWebSocketOpen(): void {
if (this.isConnected()) {
const credentials = this.credentials();
if (credentials.isDefined()) {
const request = new AuthRequest(credentials);
this.push(request);
}
this.onConnect();
let envelope;
while ((envelope = this._sendBuffer.shift()) && this.isConnected()) {
this.push(envelope);
}
this.watchIdle();
} else {
this.close();
}
}
protected onWebSocketMessage(message: MessageEvent): void {
const data = message.data;
if (typeof data === "string") {
const envelope = Envelope.parseRecon(data);
if (envelope) {
this.onEnvelope(envelope);
} else {
this.onUnknownEnvelope(data);
}
}
}