Link to home
Start Free TrialLog in
Avatar of bruno_boccara
bruno_boccaraFlag for France

asked on

To do a chat like Facebook

Hello,

i want do a chat like facebook. I know to do that, i need to use technic of polling. But when i search in Web, there is many way. I want to know the best to do that.
I see with Jquery, it is possible to do Timeout/ajax to refresh the page and get data i want. But with timeout, there is many request and i don't think it is the best way to do that.
I heard angular  but never try.

Thanks to help.
Avatar of Bill Gauvey
Bill Gauvey

Don't poll, use sockets.io or something to use web sockets.
Avatar of bruno_boccara

ASKER

Ok, i will look this. But it's hardcore to install this. I follow their instruction and it's don't work. You have a good tutorial for this ?
It is not that difficult, just visit http://socket.io/get-started/chat/ and get started.  The code for this chat example is at https://github.com/guille/chat-example

How difficult is this
var io = require('socket.io')(80);
io.emit('message', 'Hello World!');

Keep in mind that socket.io is for node.JS

Using web sockets is a bit different and a bit more coding.  Look at https://www.websocket.org/echo.html for a simple example

If you want an ASP.Net method, then check out signalR at http://www.asp.net/signalr/

Either way, just don't be intimidated by the code
I follow like they say but i don't sucess.

The first step it's ok :
{
  "name": "socket-chat-example",
  "version": "0.0.1",
  "description": "my first socket.io app",
  "dependencies": {}
}

Open in new window


The second step too:
npm install --save express@4.10.2

Open in new window


but the third and fourth step don't work :

var app = require('express')();
var http = require('http').Server(app);

app.get('/', function(req, res){
  res.send('<h1>Hello world</h1>');
});

http.listen(3000, function(){
  console.log('listening on *:3000');
});

Open in new window


i don't access at the page "hello world" when i do localhost:3000.

Sorry, first time i try to install this and it's seems very complicated for me.
ASKER CERTIFIED SOLUTION
Avatar of Bill Gauvey
Bill Gauvey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, i will try it and give a back fast. Thank for your answer.
Hello, sorry for waiting.  When i write npm install socket.io, i have many bug coming. I see many video to do this and i have always the same bug.
When i do npm install, i have error.
Avatar of Prakash Samariya
Have you check about Asp.Net SignalR?
ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization.

You can check ready example available at
http://www.codeproject.com/Articles/562023/Asp-Net-SignalR-Chat-Room
http://www.codeproject.com/Articles/889257/Chat-Application-using-ASP-NET-SignalR
Yes, of course, i saw it. But at the moment, i work with PHP so... :). But SignalR seems to be very good also for developper's ASP.
Hi,
For Realtime web application in PHP, you could try Ratchet, Socket.IO, or SockJS library.

For more in details about that, please refer:  https://entwickler.de/webandphp/building-realtime-web-apps-with-php-125787.html
Hi,
I want use Socket.IO but i don't success to install it. Many bugs all time.