AS3:Multiplayer Game by using AS3 with PHP? - php

I try to search on the Google about "Online multiplayer game" by using AS3 with PHP,because I'm going to develop Flash game that all the user can login and create his/her own character that they can walk around and Chat in the living room.
My Plan is
MySql sent User_Information to PHP then sent data to Flash (AS3) for display the information
(I try to use PHP because now I'm using PHP sever and I don't want to change it,Sorry for that)
MSQL > PHP > FLASH
I did some result from Google but I got AS3 with C#
https://playerio.com/documentation/tutorials/building-flash-multiplayer-games-tutorial/
and AS3 with JAVA
http://techylib.com/en/view/hihatclover/free_ebook_actionscript_3.0_for_multiplayer_game_and_virtual
so there are any way that I can use AS3 with PHP then MYSQL

I use AMFPHP (http://www.silexlabs.org/amfphp/) to talk to a remote server. It's free and super easy to install. Check out the documentation here (http://www.silexlabs.org/amfphp/documentation/)

There exist other MMO technologies for flash that scale much better than AMFPHP.
When building an MMO, consider how the backend will handle failure. Some level of failure from a really busy service is inevitable. The question is how many users are affected by a failure.
Scalability issues differ if the server side is a 'stateless' REST based protocol, or you are building a server that keeps state within server memory.
If you really put a load on AMFPHP, the AMF Serializer will drag the server's performance exponentially. It is simply not a linearly scalable algorithm to convert from Java to AMF serverside.
I've found that SmartFox Server (http://www.smartfoxserver.com/) is a good alternative (written in java) for multiplayer games. Its also extensible, using java. It works using Sockets, and the AMF serialization is done Client Side with the provided SmartFox ActionScript Library.
From a "quality of service" perspective, it would be intelligent to run multiple SmartFox processes on the server (running on different ports) and have each process only manage a few users. This way if a SmartFox process dies, the whole server ins't affected, only the few users being managed by that process.
A safe limit is < 15 users per process. In theory if your goal is to support 10000 simultaneous users on a server, you would have 667 SmartFox processes running on 667 different ports.
Of course this depends on the server side setup/logic, but in the simplest case, real-time MMO data from a client is simply replicated by SmartFox and broadcast to all the players connected to that process instance.
Remember, if you require further server logic, you can extend the SmartFox server with Java. But remember, the more you extend the Server, the more work is being done, and the less connections you can ultimately support (per server).

You can program Actionscript 3 in Flash Builder and it provides more advanced tools to consume PHP services, also Flash Builder is capable of generate the basic CRUD to consume these services using the Zend Framework, here is a basic tutorial for PHP programmers : http://corlan.org/flex-related/flex-for-php-developers/
also take a look here
http://www.adobe.com/es/products/flash-builder-php.html

I am working on a similar kind of game and I am using php to communicate with mysql as well.
The tutorial I am using is:
http://active.tutsplus.com/tutorials/actionscript/create-a-flash-login-system-using-php-and-mysql-part-1/
As for the playerio, I am also a bit confused.

There is a couple of multi player gaming servers are available.. my favorite one is SmartFoxServer 2x http://smartfoxserver.com/
however, you can develop a multiplayer game by using php and Flash as3 for that you have to create a PHP socket server program to handle Actionscript request. This can be achieved after you done creating PHP socket Server and you have to create socket connection from flash and connect to php socket server.
Kindly see this link for creating socket program in php :http://www.christophh.net/2012/07/24/php-socket-programming/
kindly refer this link for creating actionscript socket programming
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cfb.html

Related

Is it possible to build real-time application using PHP , Socket.io and javascript only?

Lately, I have been doing a lot of research (of course googling :P) on building real-time application (like chat application). So far I have come across Elephant.io, Socket.io and Ratchet. And some of the terms I stumbled upon were web-sockets, bi-directional communication etc..
I am building an auction site where it involves countdown timer. I am trying to achieve something like when one user bids, the timer gets updated in all the client's browser without page refresh (something like server broadcasting the change of event to all other connected users).
The problem is, I am building the application with PHP (Pyro-cms). The server, where it will be uploaded is Apache-based server and does not support node.js. One of the most common stuff I notice was most of the real-time applications were utilizing node.js.
Is it possible to build real-time application using PHP , Socket.io and javascript only? or may be with angular.js?
I really cannot use the server that support node.js so have to completely rely on apache server. I even dont know if it is possible. If there is any resources, reference or tutorial, it will be very helpful.

Real time Protocol for a web-app in PHP

I'm working on a PHP application and I'm looking for some ideas for a real-time protocol that I can use for:
1) track users status and location within the application (this should be fast!!!)
2) chat system.
I'm looking for something like FMS and its "Shared Objects" where multiple users can subscribe to pieces of information. FMS is expensive and slow for what I need, I would need a widget loaded on each page, requesting a new connection to the FMS server, etc.... slow...
I need something fast, ope source would be perfect!. Something like what Google Waves uses for syncing shared documents.
Any suggestions?
If you are willing to write this in PHP, I'd say you are looking at the wrong technology. There is 2 major problem with PHP and real-time.
When you run a PHP application, it is not persistant like Servlet with Java. It is hard and not really adapted to do communication between each connection. You have to use database storage, stream or file to send data between each instance. All of these methods are not very efficient.
It is using blocking I/O and this is where it hurts in term of performance and scalability.
You should look at non-blocking I/O technology for web server. They are all event-driven server which is something different from the PHP approach. Here are few example :
JBoss + Netty (Java)
Node.js (Javascript) - Google Tech Talk about it
Twisted (Python)
You need websockets or something similar.
http://www.orbited.org/
"Orbited allows you to write real-time web applications, such as a chat room or instant messaging client, without using external plugins like Flash or Java. It enables streaming networking for JavaScript without loading bars or page refreshes."
You can implement the chat as IRC or Jabber using Orbited.

Need help with comet, and what to choose

I'm new to comet, but I have read about it and I realize that PHP is bad for comet long polling.
All of my project is written in CodeIgniter PHP Framework, so all my code is PHP. But I need request data all seconds to update auctions products, and I'm looking for comet, but as PHP is a bad way to comet, how can I do it?
also it is possible to read from MySQL and send to listener?
Thanks.
One solution is Ajax Push Engine - they dish out their own server for handling the connections with clients, but you can use whatever backend to feed data to APE - including PHP. You can also work with MySQL directly - see example one and two. Note: the APE server can only be run on Linux, BSD or Mac OS X (though, it would seem that a port to Windows should be possible, since it's written in pure C, AFAICT).
The other one is NGiNX_HTTP_Push_Module - you use nginx as your push server (no need for an extra server running, like it's in APE's case) and the protocol is easy to work with/straightforward IMHO.
Another options would be a hosted comet SaaS solution, such as WebSync On-Demand. It's cheap, and because it's hosted doesn't have server requirements.
There's a PHP SDK for integrating your data push.
[Disclaimer: I work there]

A PHP Socket Server with Flash Clients

How do I implement a PHP Socket Server, I am using PHP5.
Is there a ready made framework already available for me to use instead of going into the nitty gritties of the implementation details?
Basically I want to serve Flash clients using this Socket Server and this would be running in an Apache Environment.
This is the first time I am treading into PHP territory so consider me a noob.
Have a look at Aleksey Zapparov's PHP Socket server
http://www.phpclasses.org/browse/package/5758.html
Its very simple to hange your own code off it. But be warned that you should be careful about your memory management. If you're writing a very complex OO app, then you should definitely install the ciercular reference checking garbage collector. And, since it use socket_select() you don't want ti to be hanging around too long witing for your code to do something.
Alternatively (if you are running on anything other than a Microsoft platform) it may be simpler to hang the php process off [x]inetd and just use stdio for communications.
HTH
C.
Check out Zend_AMF (emphasis mine)
Zend_Amf provides support for Adobe's » Action Message Format (AMF), to allow communication between Adobe's » Flash Player and PHP. Specifically, it provides a gateway server implementation for handling requests sent from the Flash Player to the server and mapping these requests to object and class methods and arbitrary callbacks.
http://framework.zend.com/download/amf
http://fritzthomas.com/php/zend-framework/329-zend_amf-update-and-examples/
and AMFPHP as an alternative.
Also, check out PHP Socket's API and check out this IBM Article about Memory Management with PHP.
Edit
This is not server push though. PHP is not well suited for long running processes. If you want a push implementation, have a look at Comet technologies.

php socket servers, actionscript 3 and multiplayer

So I am thinking about creating a multiplayer game and I was wanting to use php because I already have a php server. Is it possible to make a socket server that will be able to handle a actionscript multiplayer game. The game won't be big. so we wont need any huge amount of data pushing through. just some software that is probably reliable enough to run a multiplayer game.
PHP is clearly not a solution when it comes to socket server. It's simply not meant for that kind of usage.
If you really want to go multiplayer, SmartFox ( http://www.smartfoxserver.com/) offers a professional solution when it comes to Flash. After that developing a small socket server in a proper language is not that complicated, and the possibility are endless (Python, Java, C#, C, C++, Erlang, Go, Erlang, ...). It really depends on what kind of game you're want to do.
PHP could be eligible as a solution in case of turn by turn type game, you could simply handle it as a RESTful service (sending back and forward the game state by http).
You could use PHP, but I wouldn't recommend it. In addition you will need a shell on your server and the ability to execute custom servers, since the PHP socket server will not be running from inside the webserver (Apache etc).
I would recommend one of the many realtime communication servers available for Flash, such as Wowza, ElectroServer, Union, or others (just google for them)
There are some free ones available too, but the quality may not be as good. Some examples I found with a 30 second google serach, I know nothing about them: Oregano, GFS, Palabre
You could use Red5. It's an open source Java implementation of a Flash Media Server that allows for what you want to do:
http://osflash.org/red5

Categories