I want to receive a notification while Mysql database is updating and this notification should stop when the update finish (by adding "NEW"). I want to know the simplest way to do this .
Any idea please ?
Thanks
Yii, being a mere PHP framework running on the server, can not do such a thing. This is essential to client-server architecture. The server can not take the initiative to update the client.
The client (i.e. the user computer) can take the initiative. It can send a request to the server. Then, and only then, can the server respond to client.
You will need Javascript running on the client. The Javascript polls the server (via ajax) to see if the database is being updated. If javascript polls and finds that the server responds with: "database complete", then Javascript can add the 'NEW' logo.
Related
I'm working on a web app that involves managing users with a classic Ruby on Rails with MySQL setup.
This app also has chatbox elements. Socket.io seems like the right tool for the job, and I was hoping for some review on whether this process seems like a good idea:
Client sends chat message JSON to Rails controller.
Rails controller authenticates client and appends chat message to chat conversation JSON in MySQL server.
Rails controller sends response to client telling it MySQL server has been updated.
Client starts event on Socket.io Node server triggering it to send out updated chat conversation JSON to all clients (sockets).
EDIT: Steps 3 and 4 were updated. We go back to the client to speak to the Socket.io server after the Rails server because the Socket.io client-side library is good for triggering socket events. It also means not downloading an extra gem to mediate Rails-Socket.io communication. Let me know if this is a bad design choice.
This is the most complex project I've worked on, and I'm highly appreciative of any wisdom you guys could give me before I dive in.
I'm concerned about:
If I notify the Socket.io server to send out updated conversations the moment the user hits send, could it be possible that Rails won't finish authenticating and storing the new data in the MySQL server before Socket.io queries for it? Would it be awkward to delay Socket.io's query for a second after the user hits send? (I believe adding timers generally means I'm doing something wrong)
EDIT: I think I have the answer to the above after reading Mr. Yoshiji's comment. I'll send a response back to the client from the Rails server, and then the client will trigger the Socket.io server to update all other clients' chat. It will all be sequential with no race conditions or timer nonsense.
Would MongoDB or Redis be better than MySQL for chat conversation storage? I say MongoDB because the chat would all be JSON, and Redis seems to be used in tutorials and offer hooks for Socket.io, negating the above problem. On the downside, I'm unclear on what exactly Redis is, and I don't like the idea of adding a fourth server to this project.
Thank you for your help!
hii i am working on spring and hibernate, i have a situation when i want to call a method when changes is done in data base means like notification whenever a new notification is come then my page automatically show the no of notification, i have done this work using timer but its not good it because it call repeatedly and load on server is increased unusually so please tell me is there any way to listen the data base and call the method only when a new entry ios done or any change is made on data base
You have two options:
Trigger from database to java program using sys_exec():
see https://github.com/mysqludf/lib_mysqludf_sys
Use an hibernate entity listener. This only work if hibernate has excusive access to database.
see http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html/listeners.html
If I've understood your question correctly, you have a web interface which should show a notification, if there's a new DB entry?
Then you've first got to choose one of Jose Luis Martin's suggestions, in order to have the notification on the server side. And then you have to forward this notification to the client. For this there are a few possibilities:
(What you already did): Use polling (sending a request from client to server every x seconds, asking for new entries): http://en.wikipedia.org/wiki/Polling_(computer_science)
Let the server push the data to the client. This is the more "modern" solution: http://en.wikipedia.org/wiki/Push_technology
I'd suggest using the second approach in combination with some framework like Atmosphere: https://github.com/Atmosphere/atmosphere
This framework supports several different ways of communication, with fallbacks etc.
EDIT:
If you really just want the information inside a server method, and the information hasn't to be 100% precise, you could also use a timer on the server to count the new items every 30 seconds and kinda cache the result for the client requests.
At work we use amfphp as server and mysql as databse. What we need is that when a user updates a record the other users logged in the application can receive that update and see the update data, is that possible? Are there any libraries capable of doing this? I think that the most important part is to identify from the server the logged in users... thank you in advance.
To make this happen you will need to use a server that supports push functionality; meaning the server can send data to the client.
LiveCycle supports this, as does GraniteDS and WebOrb. I don't think that PHP does.
I have an application which runs in ofline mode also using browsers local database. Now I want my application to sync this with my server. I want to perform the below tasks
Check for a connection at regular intervals
When I have a connection send data to the server
Get the updated data present on the server.
What should I do to accomplish my above goals?
Is WebSockets a solution to it?
You do not need WebSockets for this. I would suggest simply using XMLHttpRequest. You do need to keep track of what local data is un-synced to the server (either by placing references to un-synced data in a special "queue" when offline or by having a separate field in the local DB saying "synced"). When connected, read unsynced data and submit by XMLHttpRequest.
I want to make a status report of when my FTP server is on and when its off. HTML is the language which I prefer to use. I have never used HTML before, and I need it due to a large request of when my ftp server is off and when its on.
If I were doing this, I would write an ASPNET page (or PHP, or etc) that simply connects and authenticates to the FTP server. If this succeeds, the server is online. The ASPX logic would then generate an HTML page indicating the results.
In the simple case you connect to the FTP server with each request for the page. It should cache the result though, and only check every minute, or five minutes, or some longer interval, regardless of how often a request for the status is made.
May i suggest instead of writing your own, you just install server monitoring tools on your server instead? It might be an easier choice that writing your own.
Google search
HTML is a static markup language. You might want need to use a server-side script like PHP or Perl to query for the FTP server status.