0

I have messaging all set up, but when someone sends a message, I want the recipient to see the message without having to refresh the page.

It would also be cool that when a user receives a message, there is a notification/badge that appears to indicate a new message.

I'm a newbie only just delving into web development, so is this the scenario where I would use AJAX? I've been reading about it, and that seems to be the case. Is there a better way to do something like this with Node.js + Express?

I just need a push in the right direction. Thanks!

senjougahara
  • 287
  • 1
  • 4
  • 13
  • 2
    Server Send Events, or, Long polling, or, Timed Requests, or, Web Sockets...http://stackoverflow.com/questions/11077857/what-are-long-polling-websockets-server-sent-events-sse-and-comet – Muhammad Umer Jun 08 '14 at 14:09

2 Answers2

2

THere is a very good nodejs module for long pooling - http://socket.io/ So, you can send message from server when record is updated

vodolaz095
  • 6,680
  • 4
  • 27
  • 42
1

Having the recipient see a message without refreshing a page can be achieved by AJAX. Your situation where you want the user to receive a notification message is a common one. There are several ways of achieving that. You can do short-polling or long-polling, both of which can be achieved by AJAX Scaling a chat app - short polling vs. long polling (AJAX, PHP). But if you're using Node, why not look into websockets. Node and sockets literally go hand-in-hand. Good luck!

Community
  • 1
  • 1