AutoReconnect
You can tell the API to reconnect if a connection is lost/broken. This is done by calling the autoReconnect()
method.
You can pass in a parameter (boolean) to enable/disable the autoreconnect feature. You can also pass in a timeout in milliseconds to wait before doing a reconnect.
Note: You do not have to call autoReconnect()
before calling open()
Default
This will enable autoreconnect with a timeout of 5 seconds.
<script>
var conn = new xsockets.client('ws://localhost:4502');
conn.autoReconnect();
conn.open();
</script>
Custom
Enables autoreconnect with a timeout of 30 seconds
<script>
var conn = new xsockets.client('ws://localhost:4502');
conn.autoReconnect(true, 30000);
conn.open();
</script>