Datatables and Websockets
Datatables and Websockets
I made a lot of researching about websockets on Datatables and unfortunately my research was pretty poor (or I am bad programmer on Javascript ).
I have a MySQL database with about 500.000 rows. So far, the best way I have successfully return my data back, is ServerSide with the SSP class. No matters how many results I have into my database. Have in mind that all these data are updating every about 10 seconds. With a simple ajax query every 5 seconds I could have the updated data on my client side.
The ajax return can give me TotalRecords, TotalDisplayRecords etc. So I came with the idea to have some resources savings from the serverside and create websockets. First of all, it is impossible to push 500.000 rows on initial call to first build my datatable. Second there is no way that you can send only updates through ajax ot websockets, as the updates will be again as much as the totalrecords. So my question is, how can I implement, initial start through websockets and have the functionality of serverside (SSP class) script?
PS: I am very curious why datatables are not implementing a websocket plugin or API, since, pretty much people are already trying to do so?
Regards,
Vasili
Replies
For what you describe I'd try to combine the two approaches:
Because the implementations would be very case specific. You can use
ajax
to pipe the Ajax communications DataTables uses over a socket, but much more than that and it is server specific, and DataTables core doesn't currently provide server-side scripts (the demo server-side processing script is just that, a demo).Allan
Hi allan,
Thanks for your quick reply. I ve tried do something like this:
But, I have not have to send all my 300K rows, just the first 10 of my 1st page, as per serverside request sent. As I said before, my data are changing into the DB very very quick( very often deletions, updates on the selected rows), so there is no reason to send all data as updates, just a simple reload of the first data.
Agreed - so the server-side needs to know what data is currently being displayed, so it can then stream updates for those records. So its going to be heavily dependent on whatever solution you use on the server-side.
Allan