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 / HTTP connection - server sending information to clients

Author
Message
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 25th Jul 2012 18:49
Hey there.

I've been wondering if it is somehow possible to send information from server to selected clients, with them receiving them in the same time?
Since normally it's the clients who would have to send a request to the server, so is it possible for the HTTP server to send the information to selected clients? (They'd have to listen for incoming information all the time I think)

Any ideas?

Cheers.

Follow me on twitter! @MotionStruct
Motion Struct blog
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 25th Jul 2012 19:18
Hey kamac, Was working on something like this a month ago for an idea I had. Could not figure out a way to have the server send info, since an http server really does not have a way of knowing who is connected. My solution was to have the clients poll the server for updates every 5 seconds or so. I set up a MySQL database that would contain a queue of updates and the client would send the last update number to the server and the server would send everything from that point to the last.

Was not the best solution, but worked with what was available to me. Only reason I went that path was because the multiplayer commands seem to be limited to 21 connections (including host) and I was looking for upto 50 connections.

Anyways, hope this helps some. Maybe someone else has some better information regarding this.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Jul 2012 19:24
Why not have the server log IP addresses, then let the host/clients talk directly to each other using the multiplayer commands, only getting the IP address and port from the server?

kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 25th Jul 2012 19:24 Edited at: 25th Jul 2012 19:26
Quote: "My solution was to have the clients poll the server for updates every 5 seconds or so"


Hm, yes, I've thought of that, and it seems to be the only option... But I would really need to update that in the possibly shortest time. Well, I'll think of such solution further, maybe it's the only option to go.

Quote: "Why not have the server log IP addresses, then let the host/clients talk directly to each other using the multiplayer commands, only getting the IP address and port from the server?"


That seems to be a smart solution... Though, I cannot imagine this technically.
I can ask HTTP connection for all the connected IPs, that doesn't seem to be a problem. Then, when the client has them all, I would have to connect to each one directly, or...?
A more techie example would be awesome.

Follow me on twitter! @MotionStruct
Motion Struct blog
Pilz X Schizo
17
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Massachusetts, USA
Posted: 25th Jul 2012 19:34
@BatVink: That is a good solution as long as you are using less than 21 connections. More than that and the Clients crash.

@kamac: You can poll more often, but I found that the amount of time it takes for the HTTPRequest command to send and return is about 5 seconds, may be longer from a mobile device that is not on a LAN connection. If you come up with any intresting ideas for this I would love to hear them as this has been bugging me for a while now.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Jul 2012 19:50
First, the time for the HTTPRequest command/response is very much dependent on three factors (at least):
a. your internet connect (slowest device rules)
b. the server you are connecting to (it may be a slow machine)
c. the speed your device handles things at

Second, an http server (aka web site) cannot push data to devices. It only provides information when requested. The AppGameKit HTTP commands create a connection that sends a request and waits just like your basic web browser.

Even if the http server catches the IP address (basically simple), it cannot send something directly to it. If that were possible, there would be all sorts of security issues all over the place.

Cheers,
Ancient Lady
AGK Community Tester
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Jul 2012 22:39
Quote: "That seems to be a smart solution... Though, I cannot imagine this technically. A more techie example would be awesome."


This is all theoretical, but something I've thought about for finding players globally for a 2 player game.

step 1. Each client registers itself on the website, using a HTTP request and a bit of PHP on the server.

step 2. When there are 2 players that have matching criteria (level, location, experience etc) then the server matches them. This would be done automatically on the back of the second client to register, or could be a manual selection. For a manual selection, the client would need to ask for a list of valid opponents, again using PHP to deliver the list.

step 3. At this stage the clients are still asking for information. they send HTTP requests with their unique ID, until the server returns a message telling them the details of their opponent.

step 4. Player 1 gets the "Host" message, and details of who to expect to connect (IP address, port to host on, client name)

step 5. Player 2 gets details of Host and makes a connection using multiplayer commands (IP address, port, client name to connect as)

step 6. You're off!

Quote: "@BatVink: That is a good solution as long as you are using less than 21 connections. More than that and the Clients crash."


That's useful to know, I wondered what the limit was. I've partially coded my solution to have multiple networks tied together via the host. Based on what you have said, I can have 19 users per port, and 2 spare to make the web of networks work together. I suppose you could call it a peer network.

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 25th Jul 2012 22:49
I guess what it needs is a games lobby. I've just registered a Windows Server today, so when I can find Paul's details of the networking protocols I'll see what I can cook up.

-- Jim
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 25th Jul 2012 23:20
Quote: "This is all theoretical, but something I've thought about for finding players globally for a 2 player game.

step 1. Each client registers itself on the website, using a HTTP request and a bit of PHP on the server.

step 2. When there are 2 players that have matching criteria (level, location, experience etc) then the server matches them. This would be done automatically on the back of the second client to register, or could be a manual selection. For a manual selection, the client would need to ask for a list of valid opponents, again using PHP to deliver the list.

step 3. At this stage the clients are still asking for information. they send HTTP requests with their unique ID, until the server returns a message telling them the details of their opponent.

step 4. Player 1 gets the "Host" message, and details of who to expect to connect (IP address, port to host on, client name)

step 5. Player 2 gets details of Host and makes a connection using multiplayer commands (IP address, port, client name to connect as)

step 6. You're off!"


That seems to be perfect solution, but what if the hosting guy doesn't have any open ports..?
It happens very, very often and until they're both on the same router, it's impossible to host a connection between eachother (without open ports)

Follow me on twitter! @MotionStruct
Motion Struct blog
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 25th Jul 2012 23:51
It's better to gate it on an actual server. That way there is no need for port forwarding or anything else - outgoing connections are never blocked, and the server handles incoming stuff according to its rules.

I doubt if your average user can begin to set up port-forwarding, so you need a smart lobby system.

-- Jim
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Jul 2012 00:01
I don't know how lobby systems work exactly, but they obviously do and they are very popular. One thing I do know is, most routers are pre-configured to open the relevant ports, this bit is still essential.

It's also important to understand that an open port is not itself a security risk. Something has to listen to the port, accept the packets and do something with them. If you have something doing this maliciously then you have a virus, and it didn't get in through your open port. Furthermore, the same malicious program will prefer ports 80, 8080, 21, 23, 25, 110 and the other ports that are open as standard. It doesn't need your port to act. Port scanners will also find any open port.

Having said all of that, you can't blind the average computer user with that information and expect them to act rationally, because Symantec and McAfee have already paralysed them with fear. So however the game lobby theory works, it will be interesting to find out because it's the only workable solution as far as I can see

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Jul 2012 00:47
Most multi-player games have a "lobby" system. Take Settlers 7 as an example. If I want to find some other players it will connect to the lobby and give me a list of open games, the map, number of players and so on. I can then ask to join a session. The host will either accept me or kick me until the session is closed and play starts.

All data transfers are vectored via the lobbying system. I am NOT in a peer-to-peer system: the server forwards data to all those in the session because each has an outbound connection and doesn't require any port forwarding.

Port blocking is only an issue for inbound traffic - a request to connect from outside. Using a lobby system means that it's the server's responsibility to block malicious incoming traffic, not the client user. Obviously, if you're playing on a LAN you can simply let a program through the firewall.

-- Jim
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 26th Jul 2012 02:17 Edited at: 26th Jul 2012 02:18
Quote: "It's better to gate it on an actual server. That way there is no need for port forwarding or anything else - outgoing connections are never blocked, and the server handles incoming stuff according to its rules."


Well, that's all good, but here's a little detail:

HTTP server cost - $35 a year
Cloud server cost (512mb ram + 20GB disk + Linux) - $309 a year

That is a little bit of a difference, especially when you don't suppose you will have proper income to afford that server, that's why I need to use HTTP server.

Follow me on twitter! @MotionStruct
Motion Struct blog
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Jul 2012 12:15 Edited at: 26th Jul 2012 12:16
@kamac - I understand that. But a properly developed lobby could be something that AppGameKit could host.

Alternatively, it should be possible to do the whole thing in PHP using PHP sessions and a MySQL database for games and users. Unfortunately, I can't find Paul's post describing the exact protocols for the multi-user stuff, but I seem to recall it all being strings anyway, which would make it easy for a PHP script to distribute data to connected host and client machines.

-- Jim

Login to post a reply

Server time is: 2024-11-23 19:27:12
Your offset time is: 2024-11-23 19:27:12