2
votes

Need to figure out how could one open a connection with a server and listen for constant changes from within client app in AS 3.0.

This is my first post here, so please bear with me for a few moments.

I'm trying to develop what is basically an online game that can be played by multiple players at once, from home, by installing the client i'm currently working on, to their machines. Now, i have no problem setting up the server, as it is set up to deliver XML when asked, example( gamenumber, maxplayers, currentplayers). I have chosen Adobe Air for client development. When the client is opened on a pc, it connects with the server and retrieves the XML example above, which then is shown in the main window. And here comes the question... Say i have 2 players, each at different locations registered on my website. HOW would the app communicate with the server, so that when player1 selects and opens a game from the app, and player2 joins that game, the client on player1's pc gets updated automatically... furthermore, once the game starts, and player1 takes some action in the game (pushes some button), player2 sees that. I know i can use timers, or pollintervals, for example to make the client, request a game status from the server every "n" seconds, but i am looking for a more liquid solution. For example, making the app listen constantly to the server for changes. Something like (could be a stupid ideea) implementing node.js in the app. Polling and timing works fine when it comes to a limited number of conections and data size, but if you have thousands or more, you either need a server farm, or another solution. I dont think that i will have thousands of connections, but as i develop the app, i realize that the data it needs to pull from the server increases with each new idea i have. SO... any ideas? I'd really rather not have to switch from Adobe Air to something else, but i'm open to suggestions.

1
Good question. However, you wrote quite a long story before getting to it. It reads nicer if you ask the question first, and then add more details about the problem. You may try that next time.Bas Wijnen
Thanks, i will keep that in mind next time.man
Look into broadcast techniques.alxx

1 Answers

0
votes

Well, i found an answer to my question, but not exactly a solution. In order to keep a 2 way open channel between the air app and the server, and other clients, i would need to write my own XMLSocket server, in either php, java, c++, python or whatever, and use the XMLSocket(); function in Flex. I managed to find another example here: http://www.kilometer0.com/blog/code/php-xml-socket-server/. For those of you that are looking to develop a wide platform like me, its still not the answer, as the php XMLSock still cant handle that many connections. Furthermore, as i kept reading, i see its a wee bit more complicated than your average http website, as you need to build your socket server according to your desktop app. A good solution seems to be, coding your socket server in C++, as it can handle the errors very well, and a high number of connections. Thank you for all the pointers.