Currently, my client side connection opens when I refresh the page and closes when I close/refresh the tab.
I know I can close the connection from server side but I can't find it in the documentation to do so from the client side.
I want to be able to open a new connection on clicking a button, and closing the current connection on clicking another dom button.
How can I open or close a connection from the client side?
I basically want to do this;
div.col-md-6 div.btn-group.pull-right button#button-newConnection.btn.btn-lg.btn-success(type='button', onclick="newConnection()") New Connection button#button-closeConnection.btn.btn-lg.btn-danger(type='button', onclick="closeConnection()") Close Connection
function openConnection () {
sock.connect();
}
function closeConnection () {
sock.end();
}
Thank you.
Sock.js follows HTML5 Websockets API as closely as possible. Just use .close()
on the Sock.js object:
function closeConnection () {
sock.close();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With