'Trying to reconnect..' in UI even though its connected

This commit is contained in:
Tom Wilkie
2015-08-25 09:51:32 +00:00
parent 99e28dc052
commit bd217b10db
4 changed files with 16 additions and 0 deletions

View File

@@ -30,6 +30,12 @@ module.exports = {
WebapiUtils.getNodesDelta(AppStore.getCurrentTopologyUrl());
},
openWebsocket: function() {
AppDispatcher.dispatch({
type: ActionTypes.OPEN_WEBSOCKET
});
},
closeWebsocket: function() {
AppDispatcher.dispatch({
type: ActionTypes.CLOSE_WEBSOCKET

View File

@@ -4,6 +4,7 @@ module.exports = keymirror({
CLICK_CLOSE_DETAILS: null,
CLICK_NODE: null,
CLICK_TOPOLOGY: null,
OPEN_WEBSOCKER: null,
CLOSE_WEBSOCKET: null,
ENTER_EDGE: null,
ENTER_NODE: null,

View File

@@ -157,6 +157,11 @@ AppStore.registeredCallback = function(payload) {
AppStore.emit(AppStore.CHANGE_EVENT);
break;
case ActionTypes.OPEN_WEBSOCKET:
websocketClosed = false;
AppStore.emit(AppStore.CHANGE_EVENT);
break;
case ActionTypes.CLOSE_WEBSOCKET:
websocketClosed = true;
AppStore.emit(AppStore.CHANGE_EVENT);

View File

@@ -26,6 +26,10 @@ function createWebsocket(topologyUrl) {
socket = new WebSocket(WS_URL + topologyUrl + '/ws?t=' + updateFrequency);
socket.onopen = function() {
AppActions.openWebsocket();
};
socket.onclose = function() {
clearTimeout(reconnectTimer);
socket = null;