Message Pop Up Ajax Polling(?)

He there!

If have a question that is related to two different issues I currently have in an application I’m working on.

Issue 1: - There is a message system. Users are able to send each other messages. I would like to have a real time pop up when the user gets a new message and is not on the inbox page.

Issue 2: - I would like to create a basic achievement system, one of the achievements could (for example) be: "Receive a message."

Now I think both functionalities can be achieved through the same way. Anyone of you has any experience with this? I really have no idea where to start. I am completely new with this stuff.

I thought maybe this extension: http://www.yiiframework.com/extension/yii-nfy could help me out. But after I have installed it, I have no idea where to begin. The documentation is to vague for me to understand.

It would be really great if someone could give me a good starting point.

Thanks a lot for your time.

  • interval ajax request

  • server checks for new messages for user and return JSON

  • client parses JSON and either creates notification / popup / dialog or do nothing

It’s pretty simple and can be done w/o any 3rd-party extension.

Or you can use websockets, if you have access to server.

The author of nfy extension is present on this forum, so I think he’ll clarify usage details.

It’s my extension. Sorry if the docs aren’t too clear, I’m not good at writing them and I’m not going to pretend I am. I invite you to help me improve it on Github if you manage to get it working.

That extension provides two things:

  1. A widget to fetch and display notifications using WebNotifications JavaScript API (latest HTML5). It uses the simplest ajax polling to periodicaly check for new notifications. It could be replaced with a WebSocket client for more advanced uses.

  2. A backend message routing mechanism using database for a simple queue. I modeled it after LogRouter to allow some logic to be applied when handling messages.

To make it work, you need to:

  1. Create a channel.

  2. Subscribe user to this channel.

  3. Send a message, it will be delivered to the user’s queue.

  4. Read that message (marking it as read) and display it.

The channels are there to support some more complex message routing.