Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion web/src/model/repl-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,24 @@ export const replEndpoints = cb => dispatch => {
});
};

export const replConnect = (component, endpoint, retryCount) => dispatch => {
export const replDisconnect = (component) => (dispatch, getState) => {
const existing = getState().repl.connections.get(component);
if (!existing) return;
const socket = existing.get('socket');
if (socket) {
// detach handlers so that an orphaned connection's late onclose doesn't
// clobber the new socket's state
socket.onopen = null;
socket.onerror = null;
socket.onclose = null;
socket.onmessage = null;
socket.close();
}
dispatch(replConnectClose(component));
};

export const replConnect = (component, endpoint, retryCount) => (dispatch, getState) => {
dispatch(replDisconnect(component));
dispatch(replConnectDial(component, endpoint));
const socket = new WebSocket(endpoint, ['bus.sp.nanomsg.org']);
socket.onopen = () => {
Expand Down
Loading