Client-side installation

The socket.io provides a client-side library to abstract the browser side socket connection establishment and communication. First, we need to install this library so that we can use it in our client-side code:

  1. To add socket.io to our client-side script, we have to include the external script file provided by socket.io.
  2. To view the location and latest versions of the required script files, you can visit this page: https://cdnjs.com/libraries/socket.io.
  3. As the time of writing this, the location of the latest script file is at https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js.
  4. Add this as a script file before your main script file:
    ...
    ...
    ...

       <script   
src="https://cdnjs.cloudflare.com/ajax/libs/
Chart.js/2.6.0/Chart.bundle.js"
>
</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/
socket.io/2.0.3/socket.io.js"
>
</script> <script src="script.js"></script> </body>
  1. To test whether socket.io was successfully installed, open your application in the browser and inspect the io variable in the console. If it exists as a function, you're good to go:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.253.161