ashutosh049 / codespot

Spring security websocket communication through STOMP over Sockjs
https://ashutosh049.github.io/codespot/
2 stars 0 forks source link

Reconnecting to (contextPath + '/frEP') #1

Closed ashutosh049 closed 6 years ago

ashutosh049 commented 6 years ago

function connect :

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); }

ashu89019 commented 6 years ago

On hold for now ! Bare minimum requirements are fulfilled and working as expected.