socket = new SockJS(contextPath + '/frEP');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
stompClient.subscribe('/user/queue/addFriend', function (userInContext) {
if (userInContext != null)
showResult(JSON.parse(userInContext.body));
});
}, function (error) {
console.log("error connecting frEP...\n" + error);
})
```;
We have set **isConnected(true)** to true and preserve it.. or check if **isConnected()**..??
**_to be followed :_**
function reconnect(socketUrl, successCallback) {
let connected = false;
let reconInv = setInterval(() => {
ws = new WebSocket(socketUrl);
client = webstomp.over(ws);
client.connect({}, (frame) => {
clearInterval(reconInv);
connected = true;
successCallback();
}, () => {
if (connected) {
reconnect(socketUrl, successCallback);
}
});
}, 1000);
}
function connect :
function reconnect(socketUrl, successCallback) { let connected = false; let reconInv = setInterval(() => { ws = new WebSocket(socketUrl); client = webstomp.over(ws); client.connect({}, (frame) => { clearInterval(reconInv); connected = true; successCallback(); }, () => { if (connected) { reconnect(socketUrl, successCallback); } }); }, 1000); }