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.

Newcomers AppGameKit Corner / How to make an online multiplayer game?

Author
Message
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 1st Feb 2016 12:49 Edited at: 1st Feb 2016 13:03
Hi.
I think this question have been asked couple of times already on the forum, but I couldn't find the thread I need.
Sorry if it is the 1000th time someone is asking this question.

I'm thinking about to make an online multiplayer game for android (in first place) but I have no idea what it takes, where should I start.
I have been looking through the documentation, and examples of AppGameKit and using the networking commands I have managed to make a simple app that is able to communicate on a local network and share information between two devices on the same network but I have no idea how to go further.

Basically, what I would like to do is an online matchmaking system where two player anywhere on the world able to find each other and play against each other. Or just a sort of lobby, where people could host games online and join games online.
I think I'm going to need a server side application and a client side application, but I'm just feel lost where to start. I know nothing about this.

I know it not an easy question to answer, so what I'm asking for really, just links to tutorials, documentations that could help me to understand better what it takes to setup an online connection between two devices.
Anyone could help me out with a few links and suggestions?

Thanks.
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 1st Feb 2016 15:00 Edited at: 1st Feb 2016 15:27
Construct 2 got a really nice documentation on fundamentals of how Multiplayer games works and what kind of technical difficulties we need to solve while developing an online multiplayer game which is already solved by C2 Multiplayer engine but since it is about C2, I wonder if AGK2 does helps to solve any of those technical difficulties or I need to make the whole thing from scratch.

So basically, what the C2 documentation is saying I have two options to choose from. Use a dedicated server to host a game or use something called "peer to peer" connection to let a players host the game.
Peer to Peer is exactly what I need but it lead to the first technical difficulty:

Peer to Peer connection requires a "signaling server" which would be sending a signal to the internet to let players know where to connect based on where are they, what game they are playing, what version of the game..etc, and once the player connected to the signaling server, the server would sort the players in to groups (in my case group of 2 people), and assign a player as the host, and let them play without any server get involved anymore.
The documentation does no get in to the details how to setup a signaling server, since Scirra, does offer a signaling server for people using C2.

Does TGC offers such a signaling server to be used with AGK2 so we can make a peer to peer connection?

And here is a list of other technical difficulties that C2 documentation does mention but not get in to details how to solve them since the C2 engine solves the problem for us:

NAT traversal, to connect through common home and office router setups
UDP-based transmission for minimal latency and to eliminate head-of-line blocking
Mitigation against latency, packet delay variation (PDV), and packet loss
Seamless adaption to changing network conditions
Automatic bandwidth controls to reduce redundant data transmission
Built-in local input prediction to keep controls responsive
Support for lag compensation when hit testing
Interpolation and extrapolation modes to compensate for packet loss while maintaining smooth in-game motion
Binary data transmission with control over specific datatypes to minimise bandwidth

To be honest this list of technical challenges of making an online multiplayer game sounds a bit scary since I don't know anything about it. Does AGK2 helps with any of these?

Thanks.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Feb 2016 15:51 Edited at: 1st Feb 2016 15:52
The first question is the most important - is this a realtime game or turn based?

If it is turn based, then you can use a web server to host the games. An example would be Wordspionage by Naphier.
If it is realtime, then you have many more challenges to solve. It is possible, but I don't know if anyone on these forums has attempted it.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 1st Feb 2016 16:39 Edited at: 1st Feb 2016 16:41
It would be a realtime game.

At the moment my biggest challenge is how people would be able to find each other without a dedicated server. C2 doc did mentioned signal servers, but I can't find any detail on that how it is actually operates
As long I can't find the answer I don't need to worry about any other challenges.
In fact, it may work similar to a dedicated server except it doesn't host the game, only sort people in to groups and select a client from each group to host the game I guess.

It seems a lot easier to use a server-client connection, also because of the fact it would be a realtime game but it would be just a small, free mobile game with in-app purchase and ads maybe just for fun which I don't expect could make enough money to run a reliable dedicated server 24/7 to host
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 2nd Feb 2016 12:09
I'm trying to make my own "signaling server" kind of thing in AGK2 and so far it works pretty good between PC's.
Clients connecting to the server and the server get the IP of the clients going to host the game and pass it to the clients going to join the host.

But I have a problem. Seems like Android devices unable to join a network hosted by a PC, but the signaling server must be a PC with a good internet connection and I would expect Android devices to join to find a host and play.

The server host a network using:
networkID = HostNetwork("Server network","Server1",3200)

And client should join the Server using:
networkID = JoinNetwork(ServerIP, 3200 , "client" + str(randomID) )

It works between PC's, but not Between PC and Android.
No connection seems to happen, the server does not recognize any clients connected and the Android device does not receive a Client ID from the Server.
Is it doing something with the port 3200? Should I use a different port? Or is it just simply not possible to make and Android device join a network hosted by a PC?
Anyone could help please?

Thanks.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Feb 2016 13:35
Quote: "But I have a problem. Seems like Android devices unable to join a network hosted by a PC"


It has worked OK for me. Try this tutorial, it works between any devices...
http://tutcity.devink.co.uk/first-steps-in-networking/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 2nd Feb 2016 14:16
Unfortunately it doesn't work on my side. I get the same result. I have downloaded the example comes with the tutorial and the PC and Android just unable to connect. I have tried PC as host and Android as client also Android as host and PC as client, no luck.
I get the "Network Connection Failed" message which is not a system message but a check in the example to show that message in case client is selected but the number of clients is not greater than 1 (connection to host is failed).

Thanks anyway.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Feb 2016 15:09
I tried it here, and it is working fine between my PC and Samsung Galaxy phone. I tried host and client in both directions.
It must be something on your network that is blocking it.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 2nd Feb 2016 19:57 Edited at: 2nd Feb 2016 19:58
It does works between two PC's and between two Android devices. The only case it doesn't work when I try it between PC and Android.
The firewall on my PC doesn't seem to block any connection and the app on the android devices have access to network.
It seems to me the PC and Android device simply just unable to find each other for some reason, because at least on my PC Network monitor I can't see any activity between the two (PC and Android) device.

Both of my Android devices running Android v4.0.4
I wondering if the Android version could be the problem.

Anyway, I think I'm going to carry on and when I have a chance I'm going to give it a try in a different network and using newer version of Android.

Thank you.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 3rd Feb 2016 13:40
Find the IP address on your Android (a simple way is to fire up the AppGameKit player), and see if you can ping the device from your PC. I think Android should respond to ping, unless you have a custom mod 4.0.4? I had an issue recently where broadcast stopped working for no apparent reason. My PC could not see the Android device even though both were on the same network/sub domain etc. I had to do the following to get it working:
Start a command prompt.
type:
ipconfig /flushdns
ipconfig /release
ipconfig /renew

Following that sequence of commands, all was well again. Maybe worth a try!


V2 T1 (Mostly)
Phone Tap!
Uzmadesign
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 16th Feb 2016 23:11 Edited at: 17th Feb 2016 22:59
Hi,

I a'm a bit late ...but i couldn't resist to jump in.
You asked for:
Quote: "just a sort of lobby, where people could host games online and join games online. "

Edit
Here a link to my online game: [WIP] War Balls [3D Multiplayer]
I have a Server at Home running an SQL database and some PHP scrips.
(you can use any old PC for the "masterserver")
The game host/server makes an http request to the known online masterserver.
(you must forward the ports)
The request to the php script contains IP,port,servername and so on...
The masterserver creates an Entry into the database or a line in a file.
The Clients then makes an request to the masterserver for the table or file.
Now the player can select a Server and the game tries to connect to it via the IP and port given in the table.
The masterserver is just the man in the middle.
I have an cronjob that deletes all old entrys if something goes wrong and an Server is not online anymore.
By the way there are broadcast commands to find hosts in your local network.

Just ask me if you have more questions on that
/Edit

Using AGKv2 Tier1
Zigi
14
Years of Service
User Offline
Joined: 5th Jul 2009
Location:
Posted: 17th Feb 2016 10:39 Edited at: 17th Feb 2016 10:50
CJB wrote: "Find the IP address on your Android...."

Thanks for your reply I haven't noticed after
I have tried and I can ping my android device, AppGameKit Player also works between the PC and Android I can broadcast any of the projects from my PC to my Android devices, so I'm really don't know what is going on.
The Android devices I have are noname chinese devices so they probably running a custom version of Android but apart form this situation, I have no problem with the devices.
C2 multiplayer demos also works between my PC and Android using the signaling server provided by scirra so I'm really don't know what could be the problem between AppGameKit and my network.
Everything works except using PC as host and Android as client and visa verse.

janbo wrote: "AW i wrote a long Text to explain what i did for my online lobby and after i published it, it was gone..."

I'll check back for your explanation, your game looking very nice
Thanks in advance.

Login to post a reply

Server time is: 2024-04-19 22:08:55
Your offset time is: 2024-04-19 22:08:55