Skip to content

Commit

Permalink
Magic CLOSE_NORMAL
Browse files Browse the repository at this point in the history
See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
WebSocket defines 1000 as CLOSE_NORMAL, SockJS uses it without
a name and doesn't provide one for us, so for now we define our own
  • Loading branch information
markwal committed May 11, 2015
1 parent 91bdffa commit c8b8bcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/octoprint/static/js/app/dataupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ function DataUpdater(allViewModels) {
};

self._onclose = function(e) {
if (e.code == 1000) {
// it was us calling close
if (e.code == SOCKJS_CLOSE_NORMAL) {
return;
}
if (self._autoReconnectTrial >= self._autoReconnectDialogIndex) {
Expand Down
2 changes: 2 additions & 0 deletions src/octoprint/templates/initscript.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
var SOCKJS_URI = "{{ url_for('index') }}" + "sockjs";
var SOCKJS_DEBUG = CONFIG_DEBUG;
// sockjs should define CLOSE_NORMAL for us, but they don't (from ws spec)
var SOCKJS_CLOSE_NORMAL = 1000
var UI_API_KEY = "{{ uiApiKey }}";
var VERSION = "{{ version }}";
Expand Down

0 comments on commit c8b8bcb

Please sign in to comment.