Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiplayer Flash Games

Started by Stukey Sep 18, 2009 at 4:58 AM 7 replies 3.2k views
Original Post
Stukey
Stukey
I was just wondering how networked multiplayer flash games are typically done. I found source code for game socket servers in php and perl which means the game server could be hosted easily on a regular web hosting service, but this means that any server side validity checking for game mechanics would have to be written in php or perl (I'm assuming). So is it typical for people to write gameservers like that, or do they generally write an actual standalone exe and host it themselves or find a company that will?
justkevin
justkevin
Using sockets with Flash requires the following on the server:

A PolicyServer running continuously, preferably on port 843.
A SocketServer running on any open port.

Both of these need to run continuously (not as a web page that's only at the web server's direction for a few seconds at a time). You definitely can run a socket and policy server written in perl or php but your host would need you to allow a command line process that opens ports. Most basic web hosting packages would not allow this.

The low-end solution would be a VPS with root access.

Most real-time, popular Flash games probably use dedicated servers.
Sirisian
Sirisian
Quote:
Original post by justkevin
Using sockets with Flash requires the following on the server:

A PolicyServer running continuously, preferably on port 843.
A SocketServer running on any open port.

You can put both of those together into one. A lot of people don't realize that when you try to make a connection with flash it sends a policy request and the socket server can send the policy file and the flash client will disconnect and then try to reconnect. However, the second time it won't send the policy file request and you can begin communicating. It works really well and allows you to run only one program.

For testing you can run the server on your own computer with port forwarding on your router. If you decide to go further you can buy dedicated hosting.
justkevin
justkevin
Quote:
Original post by Sirisian
Quote:
Original post by justkevin
Using sockets with Flash requires the following on the server:

A PolicyServer running continuously, preferably on port 843.
A SocketServer running on any open port.

You can put both of those together into one. A lot of people don't realize that when you try to make a connection with flash it sends a policy request and the socket server can send the policy file and the flash client will disconnect and then try to reconnect. However, the second time it won't send the policy file request and you can begin communicating. It works really well and allows you to run only one program.


True, but the trade off is only one app can bind to 843. So if you think you might run multiple apps (say a dev and a deploy version) on two different ports it might be better to have the PolicyServer run separately.
Atrix256
Atrix256
Alternately, if flash can do http requests, you could have it send / receive data to and from a php script with a mysql backend.

Might be a simpler approach than doing either P2P networking for a multiplayer game or coding (and hosting!) your own custom server application
hplus0603
hplus0603
Quote:
you could have it send / receive data to and from a php script with a mysql backend


That may work for scoreboards, but it doesn't work very well for real-time communications. There are some hacks you can add for 1-10 players, but once your game actually grows in scale, you will need a dedicated server process of some sort.
enum Bool { True, False, FileNotFound };
jsaade
jsaade
Typical network flash games needed a server listeneing on a specific port.
flash client sockets cannot communicate with each other but need to
authenticate and transmit commands using a server (a php with while 1,
listening on a port and transmitting the packets between the clients
or a hosted app on the server both do the trick).

Flash Player 10 introduced Peer to Peer communication.
The application must be first verified by Adobe, then you can
have your clients communicate between each other using UDP (which
was not available before and flash sockets were limited to tcp).

If you want to deploy a large multiplayer game on the web forget about flash,
even if you manage to optimize your traffic, the game fps will be
potentially slow (especially on older pcs), not to mention that flash games
are generally simple and have specific goals.
For browser games, I would suggest Unity3D which is a solid engine/editor and supports networking.
Sirisian
Sirisian
Quote:
Original post by ZeRaW
If you want to deploy a large multiplayer game on the web forget about flash,
even if you manage to optimize your traffic, the game fps will be
potentially slow (especially on older pcs), not to mention that flash games
are generally simple and have specific goals.

This is a common misconception that began with AS2 mostly and Flash's use of vector rendering. People began using it for games heavily. While vector rendering is simple to do it comes at a high cost to rendering performance depending on the complexity. Using techniques such as bitmapdata rendering where you use copy pixels to render allows you to render hundreds of sprites. This is accelerated by the use of cached rotations where you store rotated versions of textures and render those with copy pixels. Also with the advent of pixel bender (basically a software shader) you can do some pretty amazing effects since if you've ever looked at their software shader language it's essentially vectorization. If you know how to cull and depending on the game you won't have much of a problem.
jsaade
jsaade
Quote:
Original post by Sirisian
Quote:
Original post by ZeRaW
If you want to deploy a large multiplayer game on the web forget about flash,
even if you manage to optimize your traffic, the game fps will be
potentially slow (especially on older pcs), not to mention that flash games
are generally simple and have specific goals.

This is a common misconception that began with AS2 mostly and Flash's use of vector rendering. People began using it for games heavily. While vector rendering is simple to do it comes at a high cost to rendering performance depending on the complexity. Using techniques such as bitmapdata rendering where you use copy pixels to render allows you to render hundreds of sprites. This is accelerated by the use of cached rotations where you store rotated versions of textures and render those with copy pixels. Also with the advent of pixel bender (basically a software shader) you can do some pretty amazing effects since if you've ever looked at their software shader language it's essentially vectorization. If you know how to cull and depending on the game you won't have much of a problem.


What i meant is that for advanced browser games(3D, physics,...), it is better to use unity3D because it is a game engine that can deploy on the browser using a plugin, whereas flash was not intended to be for games. Writing a 3D game in flash is like re-inventing the wheel, even with flashplayer 10 which has some 3D components but lacks z-buffering. And writing or using a custom engine (papervision) will be like using a software renderer if you intend to use use it for some nice looking games. we are out of subject here to discuss rendering in this forum i guess, but a small example does not hurt, if you wanted to do a small car sim, load a car model (low poly) and drive it around, I would not recommend flash or any 3D engine on top of flash, we did some tests and it really is not that good, there are lots of hacks and rendering suffers slow downs, here is a sample using papervision which we did a few months ago:
http://www.whatsonamansmind.me/carGame/carGame.php

I am curently doing some tests on unity, and running the same model
on a low end laptop with a built in video card gives at lease 3 times the frame rate.

we are way off topic here so if you want to take it further I think it is better to open a topic in another forum.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.