Skip to content

Conversation

@acostarelli
Copy link
Contributor

No description provided.

sirpython and others added 18 commits August 5, 2015 21:37
Now, when initializing the API after the user has entered their login credentials, the code uses the onReady parameter of the .init function. This prevents the code from attempting to do any interaction with the socket before it is ready. However, the code does not have a spot to tell the user if they entered something incorrectly.

Also, upon sending the login request, the code will now load the lobby screen.

Idea: add an onError argument to the API init function. It should be clear what this is for.
Every 5 seconds, the code will send a query message to the server requesting all the users. Upon receiving the request, the user will be added to the list of users on the main page.

This is currently being tested and may not work.
Before, there was  bug where, when attempting to log in, the user would be forced to rapidly double click the "Log In" button in order for the screen to change successfully. Now, using something that I read on StackOverflow, the button only needs to be clicked a single time. This utilizes $rootScope and $rootScope's $apply method.

Now, on the login page, after the user has entered their credentials and they have hit the "Log In" button, this button becomes instantly disabled so that multiple requests aren't sent to the server.
Using angular's expressions ({{ ... }}) and ng-repeat, the HTML will now display the users and the chat messages. However, in the future, the chat messages will have to be in a list with a limit, so that the chat doesn't take up the entire page.
Every two seconds, this will now grab a message from the server. If the message is a "userstatus" message, it will add this user to the user list (and will later store the information about the user). If it is a chat message it will add it the chatMessages list. In the future, however, there needs to be (at least) some conditional checking for the "userstatus" messages because we don't want the list to display offline users.

However, this is extremely difficult to test because the server is not accepting my Login request.
Before, when the API was sending a request to the server, it would not include the .command of the request. Why? JSON.stringify doesn't include the inherited properties, which in our case, is .command from Message. After a quick search, I found on SO a simple function for creating a new object with all the properties needed. Now, this function is performed on the message before it is converted to JSON and before that JSON is sent to the server.
…Message

I don't know how this slipped by before, but now the code will JSON.parse each incoming message before storing it in the incomingMessages array.

The onReceieve argument of sendMessage now allows the game code to set a function to be run upon receiving a response message to the message they just sent. For example, this would be helpful when sending a LoginMessage, so you can check the welcome message to make sure everything went smoothly.
cardshifter.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest that we don't spread across too many CSS files? Your thoughts would be appreciated!

acostarelli and others added 8 commits August 6, 2015 21:38
Upon successful login, this will now create a global object containing information about the user for other controllers to use.
This function is very simple. It sends a chat message, clears the input box, and waits 3 seconds before letting the user send another chat message.

Unfortunately, there are some problems between this and the server that are currently being worked on.
…nformation

Thanks whoever made it that way. All that stress that this caused while trying to figure out what the heck was up totally doesn't matter.
Before, the code would send a query message every 2 seconds for the users. This was obviously inefficient, and could cause server problems with multiple HTML clients. Now, like the Java client, it will only add and remove users based on the query messages automatically sent by the server.
acostarelli pushed a commit that referenced this pull request Aug 7, 2015
setup a very basic lobby, added functionality to the server API
@acostarelli acostarelli merged commit ef23e76 into master Aug 7, 2015
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.

6 participants