Multiple Instances of application


#1

Hi,
I am making a small application for communicating with a server using MQTT protocol. In the code I have a bool value username_set that by default is false. When the user submits a nickname, it’s sent to the server and server return true if nickname is free or false if is taken. Depending on the received value I make some actions, like if I receive false, I create an alert(). The problem is that I want to test this functionality and I start 2 instances of the same app. In the first instance when I receive true nothing happens, works I it should, but in the second instance, I submit the same nickname, I receive false and the alert() prompts, but prompts in both instances, not only in the second. Why this is happening? And how can I test this functionality?
I want to mention that the the JavaScript code is running from the render process. The script is included in index.html. Below is a chunk of code.

  var username_set = false;
  ....
  if (!username_set) {
            if (obj.login) {
                username_set = true;
            } else {
                console.log(obj);
                alert('change username');
            }
        }