implementing a chat webapplication - php

I need to develop a web application with a chat feature, and I would like to know if there are any sophisticated ways to create a realtime web-application with a push engine.
I know jQuery, and I can handle to create a chat web-application which, in the client side, check every period for new messages, and show them, but I don't like this solution and I was wondering if there are any better ways to do it.
In my research I discovered the existence Ajax Push Engine project, and it looks like what I need, but when I was navigating in their website I found it not very well done and somehow incomplete, so I was wondring if there API is stable enough to be put in a production environment if not are there any other solutions?
Sorry if I made it long, any help/hint/link/suggestion would be very welcomed :)
EDIT
I would like to specify that I'm working with PHP in the server side

Here is an implementation in NodeJs.
http://dhotson.tumblr.com/post/271733389/a-simple-chat-server-in-node-js

I recently (year 2012) developed an application in ASP.NET MVC3 where I used SignalR for real-time messaging between server and client. At their own site, they describe SignalR like this:
ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.
... and they give the following example of what you can use SignalR for:
SignalR can be used to add any sort of "real-time" web functionality to your ASP.NET application. While chat is often used as an example, you can do a whole lot more. Any time a user refreshes a web page to see new data, or the page implements Ajax long polling to retrieve new data, is candidate for using SignalR.
Further, based on my experience, I believe it is very simple to set up, easy to use, and have a good github page with well-written documentation that gets you going in no time. I can highly recommend it :)

Related

Communication between android app and web server. Is nodejs a good option?

I went through several topics on SO but I am not sure what fits my needs as I am newbie.
I am creating an Android application for my website.
I reckon that the users can be over 800000 online at the same time.
Users will be able to:
- Submit data through the application
- Read news and updates
I want the updates to happen in real time..
The question is what approach or technique should I use?
In some SO topics is mentioned that there should be on the server side some php files that will accept http/post/get requests and they will return JSON data as feedback.
Is the above-mentioned a proper technique to serve a huge amount of users at the same time(for my standards "huge" means around 800000 users at the same time)?
I recently came across node.js. From what I read it seems like it can act as service where a user/ app can request or post data.
Can anyone give me a suggestion or links where the things are clear? How can I make sure what approach is the right one for my application?
Whatever the case is can anyone describe the right way of doing this thing?
For example: How Android chat aplications suchs as whatsapp, facebook etc work? How they do it?
I do NOT want you to post any code.. just ideas!
Thanks in advance!
If you want create an app like Facebook, Snapchat ... YES you must have a WebService, an API.
The API is linked with your database like your website and return to the app JSON, with the content of your app.
Your API (web service) can be programmed in various language as PHP, Node.JS ...
If you want to know Facebook had their API in PHP before that they created their own language.
Some other app have their API in other language.
I don't really know what is THE BEST language, the BEST language is the language which you are good with, and know it.
I think think nodejs will be best option.
NodeJs is helpfull when there are large number of clients.
Nodejs works best when building chat and gaming applications.
I think this link will help you a lot to learn nodejs.
If you are asking how facebook and whatsapp works they are implementing websockets which provides bidirectional flow of data helps in real-time communications between clients.
If your scenario is sending chats back and forth nodejs is a really good option, Most of the online tutorials you will find about nodejs develop a chat application and its super easy to do so with nodejs. Infact the biggest catch with nodejs is its easy configurations and deployment plus its lightweight. However it might be a good idea to have a look at XMPP as tech giants such as whatsapp use it to send messages and maintain presence. This link can be a good head start for nodejs learning http://code.tutsplus.com/tutorials/nodejs-for-beginners--net-26314

Does drupal or joomla allow a combination node.js and socket.io with php?

I'm looking into the development of a site where socket use is a must for real time updates. I understand with wordpress it is difficult to incorporate node.js and socket.io and was wondering if this is the case with drupal. Specifically could I incorporate node.js and socket.io with php? What specific steps would I need to take? I appreciate the help and of course if you give me a good answer, I'll rate you up.
There are currently Node.js modules that connect to Drupal, Joomla, and WordPress. I wrote the one for Joomla: https://github.com/jlleblanc/nodejs-joomla You can find all of these through NPM. First, you would download one of these modules, then you would also download the Socket.io module. Then you would write server side code connecting the CMS to Socket.io. Finally, you would write client-side code to talk to the socket running in Node.
You can have it separated and since you want some client-server communication with node.js, you can have it - outside Drupal (this is the easiest and cleanest way).
CMS you use (be it Drupal or Wordpress) does not limit your JavaScript from using socket.io and node.js for the calls you want to be made outside the CMS server-side code. You can eg. read the same database Drupal/Wordpress does, but using Node.js and returning the results directly to the client-side JavaScript script.
You can integrate Socket.IO with whatever technology you like, but you need to think of them as 2 separate parts that need to communicate.
I see 2 solutions for Socket.IO to communicate with an external service (Drupal, Joomla, Wordpress, whatever):
1) Making a rest API for your Socket.IO application (for example using Express for the API layer and then passing messages to Socket.IO with an EventEmitter).
2) The better solution in my opinion is to use a message queue like Redis, RabbitMQ or ZeroMQ. The Drupal website would send a message down the channel to Socket.IO and then Socket.IO would send that message to the client(s).
If you are creating a system that needs authentication also, I suggest you don't let your users send message directly with Socket.IO, but make an Ajax call to your main server instead (Drupal for ex.). That way you can check the user's identity more easily. (This scenario would be a fit for a chat based system that requires authentication)
Although this video tutorial is for EventMachine with Faye, the same logic could apply to your app: http://railscasts.com/episodes/260-messaging-with-faye

How to develop a real time system using PHP & MySQL

I will be working on a project for my friend. It will involve handling real time user data. Like SO, I would like to let a user login with his/her OpenID. I want advice on
MySQL db engine and or design for a real time system
authentication mechanisms
I am good at CodeIgniter and chances are I will be using it, any other suggestion
jQuery has most supporter/users here on SO and I am comfortable with jQuery as well as Prototype, out of these two which one is better or there is any other competitor to these?
The system will have users, who will be using a stand-alone client that will communicate with centralised server, one can have a view of this data on web front end.
Similar Question : Is there a way to have PHP print the data to a web browser in real time?
Javascript library is your choice.
For real time web applications trends like WebSocket, Server-Sent Events are not supported across all platforms.
You might consider checking Push Technology, Comet. Hope this gives you some direction.

Chat system in Zend Framework website

In my website, I have to make a chat system similar to Gmail so registered users can chat with their group. I have no idea about how I will do this. Can anyone provide me with an idea of how to implement this or any useful links? I have to do it using Zend Framework.
Since you are looking to work this out using Zend framework, have a look at Jaxl library (Jabber XMPP Client/Component Library). The library can be integrated with any existing website/framework and also contains several examples for browser based chat applications.
Actually there are two parts for chatting:
A long running request that streams massges from the server to the client
Ajax messages from the client to the server that sends one message to the server
For the second, any ajax framework will do it. For the first you might have a look at Comet to get the idea for this. But you should be aware that html isn't ment to be a chatting protocol. If you don't pay attention such stuff can easily kill your server.

PHP Jabber Integration

I am wondering how to integrate jabber instead of using my AJAX polling script. I chanced upon the following: http://code.google.com/p/xmpphp/
It gives me access to a jabber server, but does not tell me how to exactly go about it. I mean for example
$payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'));
Are there a fixed set of commands that I can use? Is there some site which explains the jabber workflow in very simple terms?
Thank you very much for your time.
I've been wondering about technologies to play around with XMPP, been looking at:
Strophe
BOSH
Examples of this technology can be seen at:
drop.io
Chesspark
These two doc pages seem to be fairly readable:
Core
Instant Messaging and Presence
Also, you might already be heavily invested into xmpphp, but if not, you may want to take a look at Phurple. It gives you access to the libpurple library (the code-base for Pidgin) from PHP.
From the project page:
This libpurple PHP binding, which
defines a set of internal classes,
gives a possibility to use aol and icq
(oscar), yahoo, msn, jabber, irc and
much more protocols directly from PHP.
Write your own IM chat client in PHP,
as simply as PHP enables it.

Categories