2

I'm building a project on Symfony 2.2.11 and working on a Chat script.

The concept is new for me to build, I could find the perfect solution to get online and offline users, now my question is:

What is the best way (on Symfony) to send a message on a chat box (just like Facebook), and get a realtime response when it lands on the database?

I'm aware that this will works on Ajax protocols (I know how to handle that), but my question is more on the server side.

Youssef
  • 401
  • 1
  • 5
  • 23

1 Answers1

3

You have several options:

  • WebSocket protocol, based on a php solution (React or Ratchet). For instance here is simple chat example http://socketo.me/docs/hello-world
  • WebSocket protocol, based on NodeJs. Some advantage of this solution would be better performance
  • One of the Comet techniques (for example polling)

In my opinion solutions based on WebSocket are more efficient, but they may not be supported by older browser (on the other way - WebSocket libraries mostly support fallback mechanism)

Cyprian
  • 11,174
  • 1
  • 48
  • 45
  • 2
    I love stackoverflow and I love you guys. THANK YOU, this is the answer I needed. I'll let you know if it doesnt work. – Youssef Dec 20 '13 at 14:39
  • 2
    Thanks for the answer, I used socketo.me and it worked perfectly, the only problem is that the broadcast method sends data to everyone who expects data from the given IP adress, SO, what is the best way so that I can send a specific message to a specific user ? – Youssef Jan 16 '14 at 11:42
  • 1
    It depends on solution you've chosen. But please create separate question for that with wider explanation. – Cyprian Jan 16 '14 at 12:08
  • 2
    Heres the new topic about that, if you help me dear Cyprian, that would be great http://stackoverflow.com/questions/21172442/php-websocket-zmq-chat-operation-send-data-to-specific-user – Youssef Jan 16 '14 at 21:12