Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sendFirstInBuffer = function(newMsgBuffer) {
if (newMsgBuffer && !newMsgBuffer.isEmpty()) {
try {
const firstEntry = newMsgBuffer.entries().next().value;
if (firstEntry && ws.readyState === SockJS.OPEN) {
//undefined if queue is empty
if (firstEntry.length != 2) {
console.error(
"Could not send message, did not find a uri/message pair in the message buffer. The first Entry in the buffer is:",
firstEntry
);
return;
}
const [eventUri, msg] = firstEntry;
ws.send(JSON.stringify(msg));
//console.log("messaging-agent.js: sent message: " + JSON.stringify(msg));
// move message to next stat ("waitingForAnswer"). Also triggers this watch again as a result.
redux.dispatch(
actionCreators.messages__waitingForAnswer({ eventUri, msg })
);
const error = (frame) => {
switch (this.ws.readyState) {
case SockJS.CLOSING:
case SockJS.CLOSED:
this.reconnect();
break;
case SockJS.OPEN:
default:
console.log('FRAME ERROR', frame);
this.errorCallback(frame);
}
};
const headers = this.headers || {};
let checkReadyState = function(connector) {
var self = connector;
if (SockJSBrowser ? self.socket.readyState !== SockJSBrowser.OPEN : self.socket.readyState !== SockJSNode.OPEN) {
return false;
}
return true;
}
_isConnected () {
return this.socket && this.socket.readyState === SockJS.OPEN
}
_onConnected () {
const error = (frame) => {
log('fsSocket error', this.socket)
switch (this.socket.readyState) {
case SockJS.CLOSING:
case SockJS.CLOSED:
runInAction(() => config.fsSocketConnected = false)
this.reconnect()
break
case SockJS.OPEN:
log('FRAME ERROR', frame)
break
default:
}
this.errorCallback(frame)
}