We are using XVA-04-01-Fallback package. By using this fallback project we tried to reconnect the connection when the xsocket is terminate. But the reconnect is not working.
Pls give the need script to implement the reconnect in Xsocket. Here by code we tried for reconnect
<script type="text/javascript">
var conn;
var onlyonce = 0;
$(function () {
connect();
});
//Setup a subscription for the topic "chatmessage"
var connect = function () {
onlyonce++;
conn.onconnected = function () {
subscribeTo();
$("#status").html("socket connected");
};
conn.ondisconnected = function () {
$("#reconnect").append('CLOSED, will reconnect in 5 seconds');
$("#reconnect").append("Disconnected");
setTimeout(function () {
connect();
}, 2000);
$("#status").html("socket disconnected");
};
};
var subscribeTo = function () {
conn.controller("chat").onopen = function (ci) {
$("#status").html("opened");
};
conn.controller("chat").onclose = function (ci) {
$("#status").html("onclose");
};
conn.controller('chat').subscribe('chatmessage', function (data) {
$("#status").append(data);
});
//When button is clicked, publish a chat-message
$("#send").click(function () {
var u = document.getElementById('username').value;
var m = document.getElementById('message').value;
conn.controller('chat').invoke('chatmessage', { username: u, message: m });
});
};
// });
</script>