What technologies should I use to create a real time One to One chat?

179 views Asked by At

I'm a PHP developer with a lack of experience on other sever side langages.

I’d like you to give me leads, advice, keywords or whatever that could help me refine my research better.

What I want to do is basically to create a one to one mobile app chat that will scale.

There will be channels of 3 users: User A, User B and the "computer" pushing some messages according to some channels informations like the last time a message has been sent, etc. User A should know if User B is online, writing, etc. Every conversation should be stored in a database and would be analyzed by some algorithms. Those algorithms would also analyzed stuffs on user Facebook open graph.

The application should be able to send notification on IOS and Android.

A web administration should allow admin to set some stuff that will define what kind of message would be sent by the "computer".

I'v read lot of posts about websocket, xmpp, node.js, socket.io, etc but I don't have enough knowledge in those areas to decide what architecture should I build to make everything works together. Or maybe there is some cloud base solutions that would fit my needs...

Thanks

2

There are 2 answers

2
cdagli On BEST ANSWER

As you've stated there are many ways to implement that kind of structure but I am going to write about node.js + socket.io part;

1) It is scalable. You can use cluster, nginx, haproxy. etc. to apply load balancing to your socket.io application (see here) Of course you've to use redis or mongo or some kind of store for socket.io that different servers and processes can communicate each other. (see here)

2) socket.io have rooms. That means clients and any computer bots can join that room to share events with each other. So, in your scenario User A, User B and a computer bot should join to same room and events sent to that room will be broadcasted to every room member. (events can vary as online, typing, new message, anything) (see here)

3) node.js can send push notifications both for iOS and Android.

4) You can write every message to database of your choice on new message event.

5) You can create a REST api with Express framework for your Administration page. And you can use passport for authentication and authorization purposes. You can consume the rest api with Jquery or some other frontend framework like React etc.

0
cwahlfeldt On

Meteor is very well suited for something like this and gives you everything you need. There are also open sourced chat systems built with meteor already to get an idea of where you need to go. The more custom route would be to do what @cdagli said.