Yii Framework Forum: Message Pop Up Ajax Polling(?) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Message Pop Up Ajax Polling(?) Rate Topic: -----

#1 User is offline   York 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 28-May 13

Posted 04 November 2013 - 02:42 PM

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.yiiframew...tension/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.
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 04 November 2013 - 03:17 PM

- 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.
God is real unless declared as integer
0

#3 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 04 November 2013 - 04:45 PM

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.
Don't be a dick.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users