Last active
May 24, 2017 21:57
-
-
Save frutik/7010635 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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