1 Reply Latest reply on May 29, 2015 1:01 AM by haxtbh

    Web Sockets for applications other than chat

    NVL-Tom

      I run a small call center where a small group of employees log into an authenticated ColdFusion web site.  The purpose of the web site is to poll an Access database every 30 seconds, and any consumer asking for information (having submitted a lead from a web form that posts the customer info to the database) is then promptly contacted.  At this point the process is conducted using an index page that refreshes (every 30 seconds via a meta refresh).  But I am wondering if this is a scenario that would be better served through the use of web sockets?

       

      I must say that web sockets is a new technology to myself.  And upon my attempts to learn more via examples on the web, I find that the typical example consists of a web chat interface.  That too is intriguing to myself, but I am most concerned with at this time with a means to better implement efficiencies to the index page.  I estimate that 4,000 queries are made every day against the Access database.  It works, but there must be a better way?      

        • 1. Re: Web Sockets for applications other than chat
          haxtbh Level 4

          Using jquery you can use the load() method which will load a page to an element.

           

          Simply have your page with an empty div that will have the content you are looking to refresh. Create a function with a load method in to get the data you want. When you first visit the page, the call is done for the first time, populating the data. A setInterval is setup which calls the function again every x seconds updating the div.

           

          So you could have a simple page like so:

           

          <html>
          <head>
              <script>
          
                    function loadContent(){
                         $("#content").load('pageThatContainsTheInfo.cfm');
                    }
                    $(document).ready(function(){
          
                          loadContent();
          
          
                          setInterval(function(){
                              loadContent();
          
                          },30000);
          
                    });
          
              </script>
          </head>
          <body>
              <div id="content"></div>
          </body>
          </html>
          

           

          Much easier and quicker solution then trying to get something like websockets to work to do this. Websockets will require something to "talk" to in that something in the back end will need to send messages to the front. This example above can just quickly be done on the already existing content.