Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect to the server selection on error. #31

Merged
merged 1 commit into from
Dec 14, 2015
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
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