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.
Related
Im developing a very simple native Android App containing a simple Main Menu with the Today, Yesterday, This Week, This Month and Search by Date options.
(I bought the lynda course: "Building Android and iOS Apps with Dreamweaver" with HTML5 and with the design and functionality of the app im not having too much trouble.)
What i entend with this app is this: i will write famous people profiles every day (between 1 and 5). So when people click (for example) in the Today option they will access to the profiles list that i have created for today (Yesterday and others is a check on the past written profiles from database).
So imagine that some android user clicked on today and will be presented with 3 profiles options ("Brad Pitt", "Shakira" and "Cristiano Ronaldo"), that i need the app to access my server database to update it (the "Today" profiles).
and finally...
Before the questions i want to say that i have searched on stackoverflow and found very similar answers, but im a novice on programming and when i'm reading the answers they can differ so much that i got confused going link on link documentation.
The Questions:
I want to create somekind of method that i could have a template with different profiles (Singer, Politician, Soccer Player) and click on somekind of button to start a new profile/article with Born Date, Occupation, Nationality, Biography and etc. Its this possible? How can i do it and in wich programming language?
What kind of server and what kind of database do i have to create and how to configure it to send the info to my app?
There is any server specifications that i must have for this to work the smoother and easiest possible? For this issue price is not a problem.
What kind of code should i write on my app so that it could get the "3 profiles update for today" from my website?
Its possible to show me some code example that would work with this simple step in my app of selectiong "Today" button on main menu and the app check for new profiles for today and present the user as an option? Because if i had this bit of code i could understand better how to do the rest with the profile details on the "Brad Pitt" option for example.
Hope you understood my questions. Thanks in advance. Have a nice day
Assuming that you're using the Phonegap Framework to develop your application, I would do it like so:
First of all get a Server/Webspace capable of running PHP Scripts and a MySQL Database.
You also have to rethink the way these applications work, for example you can't
configure it to send the info to my app
You need a Server Side Script (i would choose PHP for this, it's easy to learn and available on almost every Server). This PHP Script then queries your MySQL Database where all the information about the people is stored. On thing to remember is that your Clients will poll the server and request the content, you're not actively sending anything to Clients unless requested, that's just the way how HTTP works. The interface your Script is providing there is called a REST Interface.
Have a look at the link, it explains everything pretty good. Your output format should be JSON this makes it really nice to work with in the Client App later on. To do things like "what was posted today?" Have a look at how SQL Queries work and implement it in your Script.
Now for the client you can access this data by using JavaScript, most likely jQuery to simplify everything a bit. Use the jQuery $.getJSON function to access the data provided by your REST Interface. Now you can use basic jQuery to wrap this data up with HTML to present it to the user. I know that this is not "example code" or anything you requested, but it should point you into the right direction on how to achieve something like you want to do. Just do a google search for all the keywords listed above and keep reading about it, then you should be able to build a app like that.
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
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.
I know there are sites out there when you log on to their account they can play swf games or otherwise flash games on the site so whenever they go to another computer they can continue their progress without restarting just by logging onto their account.
I would like to know how they do this. So I can added it to my site. I honestly have no clue where to start to learn this. Any help leading me to the right direction. Or if you can give me some code. I would appreciate it more.
Well, you'd need to create a php/mysql based API for developers. Whatever functions you want them to be able to call in flash to save data, you'll need to code in PHP. You'll also probably have to code something to access the API, in the form of Actionscript code.
It's not something really easy that you could just "add to your site", probably the biggest thing you'd have to do is get developers to integrate it to their games. There's (unfortunately!) no magic self-implementing code which a flash developer can add to their game which has a standard serverside library, for saving data.
You'll probably want to take a look at this tutorial for the basics of how to go about implementing this.
is there a way to write a program in php or javascript that can load a flash file and interact with it? (click on buttons and such)
JavaScript
Here's a good example of Flash/JavaScript interaction using the YouTube Chromeless Player.
PHP
While you could use a query string to retrieve data from a php file or have a PHP file pre-populate FlashVars you can also use PHP with amfPHP for more robust database interaction.
ActionScript
Maybe these links will help:
Basics of using the External Interface or External Interface
There are many ways to work server/client/flash interactions into your presentations, but for what purpose would probably be the question you should be asking. I've developed a chat client that interfaces with a jabber server through java and in turn with a Sony MMPORG game. There are many interactions between the client(browser), the server(s) and of course flash. Considering it was a flash application the interaction needed to be there in order to make the entire experience a lot more intuitive and useful for the end-user.
You can see the screenshots of this client here:
EQ2 Web-Chat Client - Javascript/Actionscript/DHTML by DrLouie - Jabber/Java Communication by PC(Pierce Courtney)
Unfortunately you cannot access the live client unless you have an active Sony Station account for EverQuest 2. Keep in mind this was developed way back in 2004, so if it was possible then, it's a lot more possible today. It's a fun way to develop flash interfaces! Even more fun is finding the possibilities of flash/javascript/server interactivity, which tends to be somewhat limitless to an extent...
Look at the ExternalInterface if you are using Flex.
http://blog.flexexamples.com/category/externalinterface/
Yes, you can load a flash file (.swf) into html document and make it interact with php, but! flash is the responsible of the interaction, sending data to php, so the swf file should do it, using the loadvariables() function.
good luck!