Quick Intro: We have a flash tetris game finished and we are looking to add multiplayer functionality to the game. After a few days of research on the capabilities of flash and sockets, I've gotten even more confused. A quick disclaimer, I am new to sockets/networking in general.
From what I gathered online, general flash tcp sockets cannot handle peer to peer connections due to the policy system in place. In order for flash to do p2p, one must use a RTMFP-capable server (such as flash media server, etc) to deal with the ini开发者_JS百科tial handshakes and from there, flash is able to pass data in a p2p fashion.
Edit: See the first answer for a comprehensive update on the question.
1) For socket policy take my Perl-script or the Apache module (both work well): http://code.google.com/p/mod-socket-policy/ - it will serve clients connecting to the port 843.
But this is not enough because of corporate users behind firewalls / proxies - who can't connect to port 843, so you need to add socket policy handling to your own server code too (i.e. respond to incoming <policy-file-request/>\0 requests).
2) For RTMFP - don't do it, because:
a) Cirrus is not an option, because it is beta and not for commercial use. Also it seems to be outdated by the FMS4, so how long before it's discontinued?
b) Flash Media Server 4 option is very expensive. For the enterprise version (required for RTMFP) Adobe doesn't even list the price publicly. Your only option is FMS4 for AWS, but it is expensive too: adobe media server 4 cost with amazon?
c) There is an OSS project for RTMFP, but it isn't ready yet: OpenRTMFP Cumulus
d) For some users RTMFP just doesn't work
So my suggestion is to go with RTMP/RTMPT which works for all users, incl. corporate ones and use Red5 for that: http://red5.org/
Red5 has no support for RTMFP. Prices for Flash Media Server you will get on the adobe webpage.
There is a technology on Adobe Labs called Cirrus. It's completely free and you won't need to have special servers running besides a regular one (php, ruby...) that will perform an initial handshake (a regular http request should do it).
So, if you have for ex. 2 players that want to play together, the first one gets his Cirrus-id, passes it to your server and that value is stored in a bank of "available players". When the second client connects, the servers checks the bank and returns that id to the second player, and vice-versa. Finally, two flash-player clients establish a direct connection via rtmfp. There's also an article that explains it all in more details.
精彩评论