Creating your own asynchronous server... •--•

12357

Comments

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    Next thing to work on this evening...

    Logging the number of password attempts over a given time.

    I'll make two new columns in my users table. (or maybe a separate table)

    'Time of attempted login' and 'number of logins'

    When the number of **failed **login attempts reaches 5, I'll send the player to a page that says they have to wait 15 minutes to try again.

    When they try and login I'll check the time stamp, if over 15 minutes has passed I'll reset the login attempts back to 0, if not they're sent to the 'wait 15 minutes page' again.

    When they successfully login, the login attempts field will be reset to 0.

    I guess I'll still let them have access to the 'forgot password' route. Where they will be able to set a new password (yet to sort that route out).

    ....

    Taking a leaf out of Jon Mulcahys book, I'm going to start thinking about monitoring how much time players play in the game... the time could be tracked and stored locally in game salad, and sent out with one of the send to server rules...

  • EireStudiosEireStudios Member Posts: 451

    Excellent stuff Jon, this is the first topic I check when logging into the forums, really interesting stuff and your making it look so easy, great job man! :smile:

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,270

    Amazing. Love that log in. Makes me want to take a crack at it!

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    Cheers guys.. appreciate the feedback.. anything helps to keep me plugging away.

    got a few more bits working too now.. but I'll share that later.

    Just tidied up how I'm sending GameSalad to URLs on my server. Which should make it a lot quicker when I start switching back and forth from testing on my live server and the local one.

    For the URL addresses for the all the various files on my server, I'm telling GameSalad to SEND or GET a table file from an address like:

    http://localhost:8888/some_random_file.php

    I was storing each address in its own game attribute so it could be quickly changed... but still a bit fiddly.

    But by breaking it down into: two attributes

    part 1: main server address

    "http://localhost:8888/"

    and

    part 2: file path from within main server

    "some_random_file.php"

    then for each address rule it just concatenates a string to make the address
    "part1..part2"

    I should only have to change the one attribute for the main server address and all my addresses will know where to look.

    This would also speed things up a bit if I end up using the registration lobby setup for more than one game in the future

    Seems obvious now I'm doing it..

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    Another video update on my GameSalad asynchronous game server.

    It shows a few small and larger features.

    • It now pops up asking for the password to be between 5 and 10 characters.
    • Back button if you type the two passwords incorrectly.
    • Fully working, request a 'Forgot password' email that lets you reset your password.
    • Also there is now a working limited number of login attempts (5). That locks you out for 900 seconds (15 minutes).

    Here goes:

    Only additional registration/login related features I'd like to add are:
    If you try and login when a password hasn't been set, it should pop up and tell you to use the verification email sent out when registering. Plus give an option to request another email address verification email in case its been lost in the ether.

    I need to create a user account section, where they can press 'change password' to have the reset password email sent out. Same process as forgot email, but they might be doing it for a security reason and not because they've forgotten it.

    I also need to decide how to set up autologin. As my registration process is different now so gamesalad won't know the password to save.

    At the moment you register with a username and email. Your then able to play the game straight away. Without having to verify your email or set a password straight away. This hopefully reduces the barrier to playing the game for the first time...
    But if you close the game completely and come back, it will need you to have verified your email and set a password.

    but maybe once its been verified, if your still using the game (without fully closing it) it should check (every now and then) and see its been verified and then ask the user to enter the password to make future autologin work.

    and if they've closed the game fully, they'll be prompted to enter their password to login.

    Once a password has been entered in gamesalad to login, it can be saved alongside a username/email and automatically login without any problems. (Until they choose logout at which point the info is forgotten).

  • HopscotchHopscotch Member, PRO Posts: 2,782

    A very clean and friendly login flow that you are designing @StormyStudio!

    Be sure to limit the amount of email sending actions for one person. These things love to get abused for spamming random people with emails and your mail server ends up getting blacklisted.

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989

    Thanks @Hopscotch.

    It should be pretty sound... but you're right to make triply sure emails don't get sent via some bug I could set a time limit / counter (much like the login attempts)... which will stop a verification email being sent too many times... I'll add it to the list...

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    Holy Donuts Batman...!!

    Just got it working with a live server.. crudely running on my normal webhost.

    Time to update my copies of GS viewer on my old iphone, android phone and ipad and see if it works there too... fingers severely crossed.

    Edit: taking a bit of time.. my old iphones os needed updating... and my android SDK on my laptop also needed updating.. got it running on the ipad though, so good so far...

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    SUCCESS…

    Cross Platform - Universal - Async Login/Registration Setup - Working with Live Server

    Running on 3 devices...

    Still a little rough round the edges… but it bloody works.. Never doubted it for a minute ;)

    Gonna treat myself to a cuppa.

    Here's a little vid preview… I did consider using my tripod but...

    …Oh and 'Donkey Kong' ?… my 4 year old daughter got him in a McDonalds Happy Meal (treated by her Granny) … pretty cool.. I shall be 'borrowing it' to decorate my desk.

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    Are going to make a template for multiplayer?

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    Not at the moment.

    Too much time invested in the code and I want to concentrate on my game…

    Happy to help point fellow developers in the right direction where needed.

    It makes a lot more sense to put the time in and learn the basics of PHP scripting, some basic database management, how to install and run you own local and live server.

    There's potentially a gap to provide the GameSalad project without the PHP scripts and have everyone pay to use a server I run. But that doesn't seem to far away from Playtogethers model. Once someone gets a GS project for that working and offers it as a template there would be little point in my offering over theres.

    So instead, learn PHP, PDO database queries, basic server management, read up on encryption using PHPass or MD5 or what ever… and start building up the system.

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989

    Cheers Hopscotch...

    I know the last video did'nt really show anything new. Just 3 old shiny black devices running the same game... but the fact the server worked I felt it deserved a little video update.

    Week away next week, so any progress on this will stop for a while. Then at some point I'll start tailoring it all for my game, at which point I'll probably stop sharing updates for a bit..

  • HopscotchHopscotch Member, PRO Posts: 2,782

    I know @StormyStudio, it's a special feeling when your efforts "grow up" and actually are out in the "real world" :)

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989

    still on hols but very eager to get back to this... New big ideas...

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    Making a list for myself... (by putting it on here I'm hoping there's more chance of me doing it.. I'm still struggling to find motivation on this recently, I should have made a flappy clone instead :-) ... hopefully a wave of enthusiasm is just around the corner.

    A few simple things to add to the lobby to get me back into it:

    • Ability to swipe games from the list to delete them. Which will update the local table, the database and actors in the scene.
    • If no player 2 has joined a game, show 'Awaiting Player 2' on the game text.
    • Show usernames rather than user-ids on the game buttons list.
    • If logging into game when no password is set, check database, to ensure that is still true, then trigger a message reminding them to set a password with an option to continue playing.
    • Fix bug where if you are player 2 it's not updating the current games buttons info when you join a game.
    • Fix scrolling games list menu, so you can scroll down to update it, when there are less than 4 buttons (it works when there are more than 4). Fingers crossed I labelled all the code nicely.

    Bigger things to add:

    • Create a 'search user name' setup, which will allow you to search for a known username and invite them to play a game.

    • Make the rules that check to see if you've been invited to play a game and allow you to accept or decline. If you decline, it will delete the game, and let the original player know. If you join it, it will carry on as normal.

    Ideally I'd make some proper artwork for it all, but that's going to be as big a challenge to do nicely as finishing the rules for the thing.

    Also starting the actual top secret gameplay from scratch...

    I know the advice is always 'start small'... but there doesn't seem to be a small way to do this.

  • jonmulcahyjonmulcahy Member, Sous Chef, PRO Posts: 10,406

    no, it's a very overwhelming prospect for your own server, I know why they looked at that third party resource, this is not something that most people will be able to handle without significant investment in learning how to code

  • iamcarteziamcartez Houston, TexasMember Posts: 648
    edited April 2014

    Completely agree that this is overwhelming. I wanted to do my own server but I think I'll be going the play together route once that is fixed.

    I will continue keeping up with your progress and hopefully be able to contribute as I have a web development background myself but multiplayer is insane.

    Edit: sorry my phone is crazy but my question was have you created a live multiplayer test game/app yet?

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989

    Thanks @Hopscotch way to rally the troops.

    @iamcartez thanks.. knowing I'm being watched might keep me working.

    @jonmulcahy Agreed that's definately why they're still supporting (trying to support) a 3rd part option... it will certainly remove some of the work. Though still by no means a simple task, you still have to build and understand a working lobby and game update setup with the tables and what not which is huge in itself.

    The same old thought of 'If I could just pause the day job for a while and concentrate fully on this it would be good'.. but that's not about to happen any time soon.

    The tricky bit isn't so much knowing what to do anymore as I've kinda got a working flow for that, but more remembering what I've done so I can fix little bugs without getting bogged down re-reading my own code and rules.

    If I can get the lobby 110% perfect, I'd enjoy sitting back and making the game aspect to go with it. Plus the possibility of making some complicated tutorials for it also has a certain appeal.

  • jonmulcahyjonmulcahy Member, Sous Chef, PRO Posts: 10,406

    @StormyStudio said:

    The same old thought of 'If I could just pause the day job for a while and concentrate fully on this it would be good'.. but that's not about to happen any time soon.

    The tricky bit isn't so much knowing what to do anymore as I've kinda got a working flow for that, but more remembering what I've done so I can fix little bugs without getting bogged down re-reading my own code and rules.

    I think this every single night when I spend 15 minutes trying to remember where I left off and cram as much in before I'm too tired to think straight (much less write coherent code)

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited May 2014

    Thanks for the words of encouragement yesterday...

    Managed a bit of work last night and this morning.

    • I can now swipe the individual game list buttons horizontally when touched on the right side. simple to do, but tricky to do without breaking other rules. When released they interpolate back into position. It's the first step towards the 'delete game' functionality.
    • If no player 2 has joined a game, it now shows 'Awaiting Player 2' on the game buttons text.
    • It now shows usernames rather than user-ids on the game buttons list. i.e 'Dave vs Steve'.
    • Fixed scrolling games list menu, so you can scroll down to update it, when there are less than 4 game buttons (it previously only worked when there were more than 4 active games).

    I'll post another video some time in the future.

    Ooh.. just got my 4th Anniversary badge... (I really should have finished a lot more games by now ... ahh well onwards and upwards).

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited May 2014

    Video Update:
    Showing progress on the current games section.. the main thing being the addition of the horizontal drag function to delete games (yet to finish the delete ability) ...plus a general tidy up.

    Things I need to do:

    • Have the usernames shown with either capital letter first, or all caps, so it will look a bit tidier when displayed on the buttons. I'm still tinkering with the text layout for the buttons.
    • Write the PHP script to finish games that are 'ended' from within the game. This will forfeit a game if being played against an opponent (not completely delete it from the server). This way the other player game can find out they have won through default and receive points or add it to their number of victories.
    • Also if the game is ended and there was no opponent it can be deleted from the server.
  • zzap64zzap64 Member Posts: 405

    @StormyStudio‌, i'm sure peeps, including myself, would gladly pay $$$ for your vast time spent on this if you ever planned to release a tutorial and/or template.

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited May 2014

    Thanks @Hopscotch and @zzap64‌

    @zzap64 perhaps one day I'll do a tutorial series on it. At the moment I've got an end goal of a game in mind but it's still a long way off.

    Just updated it a little more.

    It seemed a little unnecessary to show 'player 1' vs 'player 2' on each button. As you'll already know your playing them and what your own name is.

    So now each current game buttons works out if your own gamer_id matches a games player 1 or Player 2 gamer_id in a game, and then only displays the opponents username. So it displays the text 'Playing dave' rather than 'jon vs dave'.

    Other text to include on the current game buttons:

    who's turn it is.

    'their move' or 'your move'.

    If it's been won or lost. i.e.
    'You kicked ass' or 'your a pathetic loser!'.

    (Wow! I did'nt know this forum software would bleep out a.s.s. automatically). !@#$% bull !@#$%... oh and other ones too.. (edit: I found some that it doesn't, but I won't leave those in... entertaining anyway.). I've never thought of ass as a bad word though, !@#$% yeah sure, that's bad, but ass nope, seems fine to me... 'hey look at that ass' that's fine right?...

    anyway..

    If you or they forfeited the game.
    'They gave up, congratulations' or 'Seriously, you gave up.. you make me sick!!'.

    If it's been over 3 days since a move,
    'Oie! make your friggin move', or 'Nudge your opponent to play' (push notifications willing).

    Once a game is ended.
    Add a 'rematch' button.

  • EireStudiosEireStudios Member Posts: 451

    Wow that interface looks really well man, great job!

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited May 2014

    Video Update 11. - Working 'End a Game' Functionality (No sound)

    Showing two games logged in side by side.

    One username is Dave the other is Jon.

    (One running on the latest stable build, the other on the latest Release Candidate. It won't work when running two projects from the same GameSalad Creator version).

    It shows how you can create a game,
    It displays 'Waiting for opponent'
    Another player will join that game when they create one of their own.
    if a game is swiped and ended it now removes the game button
    Plus updates on the server and so updates on the other players system (when an update is triggered).

    How does it work:

    When the 'tick' is pressed, it updates a game attribute called 'activate delete'.
    This then gets the game_id for the game button that has been swiped and ticked, (the game id is already saved in the local active games table and the row number matches the button reference number).

    It then puts the game id along with the user id into a table and sends it to the server.

    The server then checks the user_id is one of the players in the main games database for the game with the given game_id. Once it has found out that the player is indeed one of the players. It then checks to see if they are player 1 or player 2. It then updates the game in the Games database on the server, updating the winner value to the player that didn't end the game, and updating the 'whose_turn' value to 3, which I can then reference in the future so I know it was forfeited.

    I also update the time of the last move for that game. So we know when it was ended. I'll then have an automated script run on the server every 12 hours that clears out any finished games on the main games database that are over 7 days old to stop it getting to full.

    I also want to add some way so that when the 'victorious player' goes back into their game it will notify them that they have won a game by default as the other play ended it. Though I don't want to waste bandwidth having the game info brought in with an update everytime. So I need to make some rules that say, if the whose_turn value = 3, and it wasn't this player that forfeited it, then bring the game data back to GameSalad with a normal update, then a pop up can appear in GameSalad notifying the player they have won, then update the whose_turn value on the database to 4 so it is not brought in again in the future.

Sign In or Register to comment.