how to store websocket connection on client side to use it in new tab? I m using spring websockets

Viewed 233

I need to store websocket connection to use it in new tab on client side, so on opening multiple tab in same browser ,get same connection always, how can i do it?

using this funtion for socket connection:

         function connect() {
            var socket = new SockJS('/spring-mvc-java/chat');
            stompClient = Stomp.over(socket);  
            stompClient.connect({}, function(frame) {

                stompClient.subscribe('/topic/messages', function(messageOutput) {
                    showMessageOutput(JSON.parse(messageOutput.body));
                });
            });
        }

n it makes new connection when i open new tab? any solution

0 Answers
Related