creating a peer to peer game using flash and php? - php

If i want to create a website containing a game like billiards designed using actionscript 3.0, can i achieve this using php, mySQL, and AJAX? I need it to have real time updates e.g: when one player shoots the ball the other player sees it moving as well as chatting capabilities etc. Im not asking HOW to do it obviously, im only asking what language i should design the website in given that i have a flash game and want to launch it as p2p.
I have very little knowledge of building web applications and i would just like to know if i am on the right track.
Thank you.

can i achieve this using php, mySQL, and AJAX?
Yes, you can.
Look at this article: http://coding.smashingmagazine.com/2012/05/09/building-real-time-commenting-system/
But I would use node.js with socket.io for realtime communication.

Related

php based webservice for ios app for instant messaging

Hii folks i am having one question please don't mark this post as spam .I am just beginner in web services and need of a chat application on ios app .
I am using cake php for web services. i just want to know the keywords i mean how can i search for this topic i am having some keywords like socket and comet to built chat services .
please guide me just want to know how we can implement this not coding just hint me then i will Google for this .Also please tell me which one would be best because in my app while chat a user can send 10 sec video
Hey as Nishant says you have two option of REST and SOCKETS .
But problems arise in both ajax and sockets.
If you want to use sockets than PHP is not suitable for that , I suggest to use socket.io with Node.js or Erlang or Akka with Java or Scala and else if you want to use REST than you can try MySQL + PHP + JavaScript.
I can give you a short rough example of REST with JQuery:-
var lstmsg; window.onload=loadchat();function loadchat(){$.post('newmsg.php?lstmsg='+lstmsg,'xml',function(xml){/* here will be the code to handel ajax*/}); setTimeout('loadchat()',5000);}
yeah.. if you want to create a chat application than there are two main options, one is socket programming and another is ajax.....
here is a link for example of socket programming using php
http://www.codeproject.com/Tips/418814/Socket-Programming-in-PHP
but it is little complicate to understand.
I will suggest you to use ajax rather than sockets..

RealTime live notification Jquery PHP

I'm tried to implementing a live notification which is like the facebook newsticker and the notifications(on top). I was wondering what's the good solution to archieve this. I implemented an chat application before which I fired AJAX GET request in certain time to archieve the realtime, but it seems not good. I checked facebook using firebug, there is no GET request fired(or it is hided?)
Now here is my scenarion:
In main.php
I have a live ticker and a notifications button.
In bulletion.php and User.php
When I perform an add user,it will go heading to the bulletin or user.php.
How can I get informed in main.php when bulletin.php,user.php successfully created in database?
I checked this question as well before I asked.
notification system in PHP/jQuery
Realtime and php?
I was wonder,what's is long poling Ajax and session-based notification.How it can be archieved? I know Node.js can be good in implementing realtime, can it combine with PHP? and memcached ?
Any can provide sources to refer or example might be good.Thank you.
As a side note, PHP isn't really the best language to use when it comes to push notifications, it's really built around typical get/response kinda flows.
I use PHP for all my page stuff, but when it comes to push notifications of any sort I really like http://www.nodejs.org/ and http://socket.io/ to go with it. They're very easy to get setup, and will play well with you using php for the majority of your work, then using node to deal with push notification kinda stuff.
Have you thought about using HTML5 WebSockets? Have a look at EventSockets and the kickstart project on Github.
I've had much success with the server-sent events standard. It's very simple and works perfectly but it's only supported in modern browsers.
Meteor is a comet server using PHP and JavaScript to push data to browsers. It's very slick and worth a look, although it may be a little hard to setup/implement.
Edit: Quick demo here

Get data from a website to iPhone app

I have a couple of questions. I hope people can give me a good view because I am stuck at the moment.
It's a year since I started developing so please bear with me.
How can I get data from a website that I don't own to my application?
I have done some database parsing before but that's all from my own website. I see people use different library's (HPPL for example).
But what if the website requires users to login? And besides does that work on HTML only? What about if it's a PHP based site?
Should I get the external data directly on the iPhone when opening the app or should I use a middle-man approach (server between external website and app that handles the info)?
3) What is the best way to save login information so that a user doesn't have to fill in every time he opens the app?
I am a bit confused about all the stuff so maybe you can clear things up.
The question is extremely broad; so you will get pretty general answers.
Essentially, you are asking how to consume a web service. For that question, I'd recommend one of several tutorials online, like this one. There are others. That should give you a start.
You should understand the Cocoa URL loading system. The documentation is very complete. You can certainly use third-party libraries for this, such as AFNetworking; but I would recommend you understand the Apple -provided frameworks first.
But what If the website has a login ?
Depends on what sort of authentication we're talking about.
And besides does that work on HTML only ? What about if it's a php based site ?
No. Should be no different.
should I get the external data directly on the iPhone when opening the app or should I use a middle-man approach (server between external website and app that handles the info)
In general, a simple design should be favored over a more complex design so long as it meets your specifications. There's probably nothing the intermediate server can do that the iPhone cannot - but we don't really know your specs.
What is the best way to save login information so that a user don't have to fill in every time he opens the app I am a bit confused about all the stuff so maybe you can clear things up...
You will want to investigate the Keychain then. See this SO question for a bunch of tutorial references.

Integrating a JavaScript chat in a php web based game

Is it possible to implement a JavaScript plugin/app in a web text based game? if it is, how is this done. I don't really need the codes. All I want is the functionality. Basically, I want a player in the game to talk to another player in the same game. Like if he(player) enters a room, I want him to see a player and communicate with him or her. Remember, it is chatting with another player, not another user.
Also, I want the php code used to integrate this app onto the site.
WebSockets are part of HTML5 and fit in my webbased game just neatly. There is a full guide on http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/
you can use long polling with js/jquery ajax calls to the php scripts and the database (or files) to make a chat like program
Try searching for some open/free libraries that you can integrate with your game if you don't want to spend time implementing the chat part yourself. I just found this - https://blueimp.net/ajax/ but I have not used it, so you may want to take a look at the features and if it works for you.

How to store or share live data between PHP Requests?

I want to start a project for facebook and the application will be like real-time multiplayer chess game. The problem I'm having is I have no idea how to store the data when a player moves one piece and update the new position in player2 browser. I'm gonna use PHP, MySQL for server side and jQuery for Client Rendering. The simplest idea is to store the data in XML or MySQL and re-generate the result to player2 browser. But I know that when thousand of players are playing, it will not be an efficient way. Since I don't have time to study new language for this project, I'm gonna have to stick with PHP. I'm not going to use flash either because I want my client side light-weight and flash-free. So is there any way that will solve my problems?
you would have to be polling server for update every.. maybe 2 seconds, depends on server load. If you used flash, there would be another option - to use sockets, it's much more suitable for multiplayer games, but i don't think you could make it without some third-party runtime.. HTML5 has some kind of websockets, but it's very bad when it comes to cross-browser compatibility
I guess going through a server is your only option. That is to store the game status is xml or a sql db. And than the clients need to frequently poll this status, e.g by jquery ajax. Having the clients to communicate directly p2p is not possible with standard web components.

Categories