Skip to content

Conversation

@acostarelli
Copy link
Contributor

No description provided.

Before, all the available servers were hardcoded into the select in the login form of the login page. This made adding new servers a bit more difficult, because an entire new element would have to be added each time, which only leads to copy paste coding.

Now, all the servers are stored in $scope.servers, which is an object that is mapped [server name: server address]. Then, through use of ng-repeat, a new <option> is created for each server under the select.
Before, servers were stored in an object like this: [name: address]. Of course, this does not include enough information for the user. Is the server online? What about the users? How many of those are these? And the latency? I'm I going to be stuck trying to send a chat message?

Now, the servers are stored in an object like this:

name:
    address
    isOnline
    userCount
    latency
…ation

At the top of the login page, there is now a table that holds 4 pieces of information for each server: the server name, whether the server is online or not, the amount of users on the server, and the latency of the user's connection to the server
The updateStats function so far initializes the API and gets a latency count by storing the time before the init call and getting the time after, and the code can easily find out if the server is online if the connection is made at all.

This currently does not work and is being tested.
…o checking for "Other..."

Now the code sort of works. It will only display information for stats.zomis.net, but the latency is blown out of proportion: I was reaching 2000+ ms. I think the reason for this is because the server is being queried to quickly, so by the time init's third parameter runs, it is using an old local `now` variable.

Another issue: this will not recognize a local host server.
Instead of checking the server stats every 2 seconds, there is now a refresh button. There are still some bugs to be worked out, for example, if the server does not exist (local host), then the code dies. And, if the server does exist, the code may sit waiting for a response indefinitely, even though one may never be received. And, this refersh button allows for an easy attempt of a DoS on the server.

Maybe this idea should be put off for a little while.
This class is used to store information about each server for the server status table. It holds information like the user count, the latency, and whether or not the server is online.
Before, when the ServerInfo object was being created for "Other", the name was set to null. However, the login code checks to see if it is equal to "other", so this was changed: null --> "other"
This has a bug: the HTML is not updated.  Perhaps this has to do with the fact that this is async.
When this button is clicked, the server stats table is updated with the information about the servers.
Now, the user can only hit the refresh button only every 3 seconds
…s with the local variables passed into it.

Before, when this loop inside $scope.refreshServers was running, since API.init is async, the loop would finish instantly and the local `thisServer` would be the very last server in the list. Now, an anonymous function is passed to the init method that is given the current server when it is passed in so it does not change in that function's scope.
It is quite easy to attempt and crash a server just by smashing the "refresh" button. Right now, there is an interval setup to disable this button for a certain amount of time, but it still needs some work (aka: it doesn't work)
The two anonymous functions that were being passed to API.init have been removed. Now, the entire API.init call is encased in an anonymous function.
Apparently, [] in javascript is a truth value, so just checking if(eventTypes) will always be true as long as eventTypes is an array.
Zomis added a commit that referenced this pull request Sep 20, 2015
@Zomis
Copy link
Member

Zomis commented Sep 20, 2015

Is it possible to have it automatically do the "Refresh" when the page is first loaded?

@Zomis Zomis merged commit c87da4d into develop Sep 20, 2015
Zomis added a commit that referenced this pull request Sep 20, 2015
@Zomis Zomis deleted the server-stats branch May 27, 2018 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants