K
K
Kotik Meow2019-07-01 23:52:09
Node.js
Kotik Meow, 2019-07-01 23:52:09

Why does the application behave strangely when authenticating?

Faced a very strange problem in my application - a chat with authentication through social networks and saving message history. The technologies that I used are indicated in the tags. The essence of the problem is as follows: I open two windows of the client application and when I try to log in in the first window (on the authorization page there are 2 VK and Facebook buttons), authorization occurs in the second (i.e. enters the chat, loads the message history). Moreover, if I try to log in again through the first window, the second window will log in again, i.e. messages will be loaded again and the name will be updated (I have different names in VK and Facebook). I noticed one more oddity, if you duplicate the second window, then everything works as it should in the third window, the same thing will happen if you open only one window - everything will work fine. Tell,
project source code: https://github.com/AleksandrVais/Chat

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-07-02
@AlexVais

On your server id is a global variable. Do you really not see this as a problem?
The server can process messages from thousands of clients at the same time, but due to the use of a global variable, all responses will go to the one who connected last. And this, at first glance, harmless line will assign existing id with the subsequent loss of active connections from the clients object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question