-
Notifications
You must be signed in to change notification settings - Fork 5
setup a very basic lobby, added functionality to the server API #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
updating branch
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
There was a problem hiding this comment.
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!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.