Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK Networking Question

Author
Message
aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 26th Sep 2014 16:03
With the help of this wonderful forum community I have successfuly finished my first Bingo network game in AppGameKit and It is now available on Appstore and Google Play called Bingo Home Network. This game allows multiplayer Bingo and live chatting with a game lobby across your local network only. My future version which I'm working on soon will provide the capability of WLAN but I obviously have to learn a little more and I have the concept but want to hear some feedback for my idea:

I want to use AppGameKit HTTP commands through PHP scripts to connect to my online server database. When a player wants to host a game a new record is inserted into the database with HOSTNAME, HOSTIPADDRESS & ISHOSTING fields. When the host disconnects or quits game his/her ISHOSTING field will be set to FALSE so this HOST link will not show up when another player searches for available HOSTS.

When another player wants to join a game he/she will access the server database and retrieve the current available HOSTS (HOSTNAME and HOSTIPADDRESS) where ISHOSTING = TRUE. Then viola we have a Bingo Game in session.

Is this typically how this should be done? Am I on the right track? (I am pretty good with the AppGameKit HTTP commands communicating through PHP connecting to a database.) Any other suggestions?

And there is only one thing I cannot do or don't know how to do it in AGK:
How can I find my IP ADDRESS using AppGameKit? Most people don't have a clue how to manually find their IP so I want to automatically fill in this info when a host wants to setup a new host server.
unlikely
12
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 26th Sep 2014 16:37
Quote: "And there is only one thing I cannot do or don't know how to do it in AGK:
How can I find my IP ADDRESS using AppGameKit? Most people don't have a clue how to manually find their IP so I want to automatically fill in this info when a host wants to setup a new host server. "


You could easily parse it from one of the many ip address web APIs available. This one seems super easy to use:
http://bot.whatismyipaddress.com/

They only request that you make around one request every 5 minutes, per user, though that is not a strict limit.
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 26th Sep 2014 21:07
Couldn't you just use $_SERVER['REMOTE_ADDR'] in the PHP server to fetch the public ip from the user when they say they want to host a game? That way you don't need to fetch it from AppGameKit at all.

How will you deal with crashes? Will there be some kind of ping, and a timeout to remove games that have not pinged the server for a certain amount of time? Also would there be any problem with dynamic ips potentially changing during the game? Just some thoughts.

aviles22
10
Years of Service
User Offline
Joined: 1st Dec 2013
Location: New Jersey, USA
Posted: 26th Sep 2014 23:07
Quote: "Couldn't you just use $_SERVER['REMOTE_ADDR']"


Awesome thank you. Probably exactly how bot.whatismyipaddress does it.
Also will be one less trip to the server in code as I could just have PHP return this right in the same script as my database insert code.


Quote: "Will there be some kind of ping, and a timeout to remove games that have not pinged the server for a certain amount of time?"


When a host closes a game or exits the app my idea is to also delete the record with that host data.


Quote: "Also would there be any problem with dynamic ips potentially changing during the game?"


Ok now thats why I created this post for some ideas. I didn't know IP's can change that frequently as I wasn't planning on saving the host IP's for more than 1 session.
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 26th Sep 2014 23:40 Edited at: 26th Sep 2014 23:40
Quote: "When a host closes a game or exits the app my idea is to also delete the record with that host data."

That makes sense, but I mean, what if it crashes/the computer turns off at the wall/the internet drops? Then you wouldn't have the opportunity to run any shutdown code.

Quote: "Ok now thats why I created this post for some ideas. I didn't know IP's can change that frequently as I wasn't planning on saving the host IP's for more than 1 session."

You're right, you'd probably be fine. Dynamic ips don't change very often in most places so although it's possible, the number of users who'd be affected would probably be tiny.

Login to post a reply

Server time is: 2024-11-25 10:47:55
Your offset time is: 2024-11-25 10:47:55