Jump to content

how to send global alert to all the users in a php application?


krishna.p

Recommended Posts

Hi Experts,

      Is there a way an admin user can send an alert message to all the users who are currently working on the application. for example, 2 users are working on my application. Now admin user logins into my application and enter some text like "This application will not be available for the next 2 hours. Sorry for the inconvience." in a textbox and clicks on SEND button.

      In this scenario, the 2 users who were currently logged in should get that alert as soon as admin user clicks on SEND button.

      Would appreciate if you guys can help me out in solving this problem. Thanks in advance.

Link to comment
Share on other sites

if i were doing it i'd have an error table in my database (+ there will now be an audit trail of errors/messages displayed)

i'd have that table set up like

id username dateTimeStart dateTimeEnd error usersViewed

 

then i'd have a javascript function which posted to a php page every five minutes using the setTimeout("checkErrors()",30000); and if that page returned anything it would make a div pop up and display the error message...

 

then the php page would using mysql and the user's ID and check if there are any errors where currentdateTime > startDateTime and less than dateTimeEnd

 

then i'd have all the userID's of people who had seen the error message in the usersViewed seperated by commas

 

i'd pull that and use PHP to explode(",", $errorDetails['users']) so that they were in an array

 

then i'd use the in_array function to see if the user had viewed the error

 

if not, i'd make the php echo the error message and the javascript function checkErrors would register this and popup teh error div and display the error message...

 

the php function would also have to add the usersID to the usersViewed column.

 

make sense?

Link to comment
Share on other sites

if i were doing it i'd have an error table in my database (+ there will now be an audit trail of errors/messages displayed)

i'd have that table set up like

id username dateTimeStart dateTimeEnd error usersViewed

 

then i'd have a javascript function which posted to a php page every five minutes using the setTimeout("checkErrors()",30000); and if that page returned anything it would make a div pop up and display the error message...

 

then the php page would using mysql and the user's ID and check if there are any errors where currentdateTime > startDateTime and less than dateTimeEnd

 

then i'd have all the userID's of people who had seen the error message in the usersViewed seperated by commas

 

i'd pull that and use PHP to explode(",", $errorDetails['users']) so that they were in an array

 

then i'd use the in_array function to see if the user had viewed the error

 

if not, i'd make the php echo the error message and the javascript function checkErrors would register this and popup teh error div and display the error message...

 

the php function would also have to add the usersID to the usersViewed column.

 

make sense?

 

yes , Thanks for the reply.. now i got some idea.. Also will it have any performance issues? i.e.. i will have around 200 users working on my application. then if use javascript interval function for every 5 minutes to check the error, then i will get around 1000 requests at the end of 5 minute right? heavy load on server?

Link to comment
Share on other sites

1000 requests?

you'd get 200 requests every 5 minutes, you could set it to ten.

and these requests would only happen if 200 users were logged in, in which case each page they view would most likely require SQL queries anyway. so if only 30 users are logged in, you'll have 30 requests every 5 minutes

Link to comment
Share on other sites

1000 requests?

you'd get 200 requests every 5 minutes, you could set it to ten.

and these requests would only happen if 200 users were logged in, in which case each page they view would most likely require SQL queries anyway. so if only 30 users are logged in, you'll have 30 requests every 5 minutes

yes sorry its 200 requests.. if i set it to 10 mins in the worst case the users will be seeing the alert message after 10 minutes. i think this interval should be as minimum as possible..However i will give it a try..Thanks once again..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.