April 2018
Beginner
226 pages
4h 47m
English
Now we are going to connect our client, index.html.js, to the Socket.IO server by adding a client-side script, as follows:
<script src="/socket.io/socket.io.js"></script><script>const socket = io();</script>
Just add the about script tag after the end of the body tag. socket.io.js handles the connection to the server on invoking the io prototype method. By default, it establishes the connection with the same URL through which the socket file was served to browser. It also provides an option to set the connection URL differently by passing it as a URL string parameter.
Once the connection and disconnect listeners are implemented and the client is also connected, on the browser refresh, we will receive the log, ...
Read now
Unlock full access