169 похожих чатов

I am building a chat server So for storing a

websocket connection I am using the hashmap where key will be the userid and value will be the user socket channel

I want the user to connect the same account from multiple phones so when the user login again the socket channel gets replaced by the latest user login

How do I solve this issue
Isn’t hashmap a good idea to store the connection ? If not how do I store it.

3 ответов

5 просмотров

What abput the other phones? How do they get the messages they are logged in for? When you do this, you are implementing an hidden one device rule that the few users with multiple devices confuse.

Athul-N Автор вопроса
Sebastian
What abput the other phones? How do they get the m...

I want like how telegram does it When we logged in other phone we will get all messages

Athul N
I want like how telegram does it When we logged i...

Telegram wakes up in the background and fetches messages. When the App is open there is an permanent connection for updates. If i have the desktop and tge phone app open, both get the updates, your approach would be that the latest approach gets the update. I would implement the server side in a way that there are two api-endpoint where updates are get: 1. An query for past messages, it returns all the messages past an point of time, for first logins and when an device was not online for a time, if its implemented so it can stream the data it can be implemented more responsive 2. An websocket based one that returns messages from an pub-sub system that saves messages before submitting incoming in an database for endpoint 1. I would implement the pub sub system that it uses groups for each chat/group and that each websocket connection subscribes to the groups. This way you can implement it with redudancy from the start.

Похожие вопросы

Обсуждают сегодня

Комрады, хотел уточнить. Проперть в OnDestroy юнита-хозяина по-прежнему доступна? И еще уточнение: finalization юнита наступает раньше или позже OnDestroy?
Ed Doc
40
Проблема с Windows scripting control Множество объектов получают iDispatch обертки и отдаются в скрипты. При этом скрипты могут эти обертки держать живыми очень долго, наприм...
Arioch The
16
Скажите, можно ли как-то "переместить" динамический массив из одной переменной в другую? Скажем, переместить из TList<> в TArray<>. Именно переместить, а не скопировать. Если ...
Eugene Krasnikov (ᴊɪɴ x)
37
Я тут пытаюсь переработать архитектуру подсистемы памяти ядра во что-то осмысленное. Есть pmm, который создает набор range’ей(пока что только для ядра, потом для юзерспейса), ...
Evg Resh
9
комрады, че-та лыжы не едут var tmpFont: TFont; begin tmpFont:= TFont.Create; try case rgFontColor.ItemIndex of 0: tmpFont.Color:= clWindowText; 1: tmpFo...
Ed Doc
34
Вот еще криповенькая штука. uMain.pas(517,3) Warning: Case statement does not handle all possible cases И ЧО? 😂
Александр (Rouse_) Багель
20
Интересно, нет ли какого-то способа получить из dll не адрес самой метки, а адрес со смещением?
The Bird of Hermes
54
то есть у тебя там Лазарь, не делфя?
Handatros
8
М-да. Почему бы просто со stringlist не работать?
Michael Longneck
23
коллеги, а есть простой способ определить, что программу из под Delphi запускают?
Михаил
10
Карта сайта