Skip to content

Commit

Permalink
Merge pull request #31 from rgbkrk/handle-socket-errors
Browse files Browse the repository at this point in the history
Redirect to the server selection on error.
  • Loading branch information
rgbkrk committed Dec 14, 2015
2 parents 90c8774 + 5418774 commit 6c53d79
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ export default class App extends React.Component {
discover()
.then(server => createSocket(server.info.address))
.then(socket => {
// Redirect to server selection on disconnect (for now).
// Since close always follows an emitted 'error' on socket, we'll only
// redirect in close.
socket.on('close', (hadError) => {
if (hadError) {
console.error('Connection to Fallout 4 server had an error. Redirecting to server selection screen.');
}
this.props.history.pushState(null, '/');
});
socket.on('timeout', () => {
console.error('Fallout 4 timed out.');
socket.destroy();
});
socket.setTimeout(2000);

this.cancelHeartbeat = sendPeriodicHeartbeat(socket);
this.connection = createConnectionSubject(socket);
this.subscription = this.connection.subscribe(x => {
Expand Down

0 comments on commit 6c53d79

Please sign in to comment.