Skip to content

Instantly share code, notes, and snippets.

@frutik
Last active May 24, 2017 21:57
Show Gist options
  • Save frutik/7010635 to your computer and use it in GitHub Desktop.
Save frutik/7010635 to your computer and use it in GitHub Desktop.
var Channel = function(url, connect_callback, disconnect_callback) {
var url = url;
var connect_callback = connect_callback || function() {};
var disconnect_callback = disconnect_callback || function() {};
var conn;
return {
connect: function() {
conn = new SockJS(url);
conn.onopen = function () {
connect_callback();
}
};
conn.onclose = function () {
disconnect_callback();
connect(); // try to reconnect
};
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment