Skip to content

Commit

Permalink
Document the GitHub Pages hack
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Aug 15, 2024
1 parent ba43753 commit a037eea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions game.mts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,14 @@ export async function createGame(): Promise<Game> {
};
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = new WebSocket(`${protocol}//${window.location.hostname}:${SERVER_PORT}`);
// HACK: This application is deployed to GitHub Pages for the demo
// purposes. Unfortunately, GitHub Pages only allow hosting static
// assets, so we can only operate in Offline Mode. At the same
// time, tsoding.github.io accepts WebSocket connection on the
// port 6970 and later times out on the shandshake which results
// in the client displaying "Connecting..." for the whole time,
// which does not look good in the demo. So if we are on
// tsoding.github.io we just instantly close the connection.
if (window.location.hostname === 'tsoding.github.io') ws.close();
const me = {
id: 0,
Expand Down

0 comments on commit a037eea

Please sign in to comment.