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

Align web socket commands with LiveView server #397

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

etopiei
Copy link

@etopiei etopiei commented Jul 27, 2020

Currently the web socket commands are not named the same way as those used by the LiveSplit server component.
I have written a script to connect the Android Remote app to LiveSplitOne (here) but as some of the commands are different and/or not supplied it is tricky to get this working. In order for more tools to be able to interface better with LiveSplitOne I think it would be good to have standardized commands that are the same as the desktop app.

I am fairly new to this code base, so let me know if anything needs to change or could be done differently, I'm open to feedback and different ideas of how this should be done. This is currently more of a POC, but I'd be happy to help bring this to LiveSplitOne.

case "togglepause": this.togglePauseOrStart(); break;
case "undo": this.undoSplit(); break;
case "skip": this.skipSplit(); break;
case "pause": this.togglePauseOrStart(); break;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this to either stay togglepause or for pause to be a (deprecated) alias.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good idea, I'll fix that up 👍

@CryZe
Copy link
Collaborator

CryZe commented Jul 27, 2020

Considering there's all sorts of new functions dedicated entirely to the WebSocket communication, I'd probably also would want to see all of this logic moved out into a new source file.

@etopiei
Copy link
Author

etopiei commented Jul 29, 2020

@CryZe I've re-worked this a bit as you suggested, hopefully this is looking a bit better now. Let me know if you'd like any other changes or would like to try things another way. Cheers 👍

@@ -353,4 +368,4 @@ export class TimerView extends React.Component<Props, State> {
private resumeGameTime() {
this.writeWith((t) => t.resumeGameTime());
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure that there are newlines at the end of files?

} else {
return parts[0] + ":" + parts[1].slice(0, parts[1].length - 1);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

} else {
return "";
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we just do:

return phases[phase] || "";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should use expect(phases[phase], "Unknown timer phase supplied") here or so, as the index out of bounds case should visibly explode and not implicitly do something weird.

return "0" + parts[0] + ":" + parts[1].slice(0, parts[1].length - 1);
} else {
return parts[0] + ":" + parts[1].slice(0, parts[1].length - 1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems really hacky. Could we either modify formatLeaderboardTime to take additional arguments or just add an additional method to TimeUtil?

@CryZe
Copy link
Collaborator

CryZe commented Jul 29, 2020

While you've moved some functionality over into WebSocket.ts, I'd actually like to see all the WebSocket logic be moved over. There should be close to nothing left in the TimerView.

@etopiei
Copy link
Author

etopiei commented Aug 11, 2020

@CryZe Sorry this has taken so long, I've been a bit busy lately, but I've created a new WebSocket manager class which handles the web socket setup and communication. I think this is looking a bit cleaner now, but let me know if there are any further changes required. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants