D
D
dikkini2014-03-30 20:52:19
JavaScript
dikkini, 2014-03-30 20:52:19

Java Spring - how to organize user communication?

Hello, I'm writing a web application in which there is communication between users (like in facebook, vk etc).
There was a question about implementation. Spring 4 introduced the so-called websockets using sockjs and stomp on the client side. The architecture of the messages is as follows:
On the client, I send messages to "subscribe to the conversation", pass the conversation id in this message and subscribe to the topic for receiving new messages, a thread is launched on the server that checks for new messages for the conversation and, if available, sends it to the client.
Further, the logic is as follows, when you click on another conversation - a message is sent with a different dialogue id, the previous scheduler is canceled and a new one is launched for a new dialogue.
And everything is fine until the user opens another tab and tries to chat in another tab or in both at once. Problems arise immediately. Several subscriptions, in one tab the user decided to chat with user B, and in the first tab he chatted with user A - and this thread was canceled. of course. How to solve the problem of multiple tabs? Or did I choose the wrong architecture?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Metalfire, 2014-04-20
@dikkini

stomp alternative: habrahabr.ru/post/220015

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question