ninegua / reversi

Multiplayer Reversi Game on Internet Computer
https://ninegua.github.io/reversi
MIT License
66 stars 25 forks source link

player is global when run locally #6

Closed nquinlan closed 3 years ago

nquinlan commented 3 years ago

Let me preface this with the fact that I am an absolute novice when it comes to DFINITY, the Internet Computer, and Motoko.

However, when I follow the installation instructions and open the frontend on my machine, it allows me to create a game, but when I load the frontend in an incognito tab or on a different device, I'm presented with a screen insinuating I'm the player who created the game. Example below:

  1. $ dfx start --background
  2. $ make install
  3. Load canister URL
  4. Create game, Player 1: Nick, Player 2: Rick
  5. Open incognito mode, load canister URL. I'm presented with the following screen.

image

This is different than the behavior I see when I open your online example application. What I am I doing wrong and/or what would I need to do to enable the multiplayer capability of the game?

$ dfx --version
dfx 0.6.14
ninegua commented 3 years ago

Thanks for reporting the problem. I've yet to try the new SDK, but the example app I hosted myself was using version 0.6.4, which was several months old. Meanwhile I guess you can always open two browsers.

nquinlan commented 3 years ago

Thanks for your response! I really appreciate it on a demo app!

I don't think it's a browser issue. I've gone so far as to open the app on a different device and it still just assumes that I'm the original player.

In the meantime, I'll try it at SDK 0.6.4 and see what happens.

Thanks again. You rock! 👨‍🎤 😃

nquinlan commented 3 years ago

It worked with sdk@0.6.4. I made a PR to update the dfx.json so that anyone trying to run the app locally gets a working version.

ninegua commented 3 years ago

Just tried with dfx 0.6.21, Firefox web console says there is an exception when I try to load the game from a private window. But I have no problem playing as two players, one from firefox, and the other from microsoft edge.

ninegua commented 3 years ago

Something like this:

Uncaught (in promise) DOMException: A mutation operation was attempted on a database that did not allow mutations. index.ts:91:8
    <anonymous> index.ts:91
    (Async: promise callback)
    <anonymous> index.ts:84
    Webpack 3
ninegua commented 3 years ago

Also no problem playing as two players using just Microsoft Edge (which is essentially Chrome), one from a normal window, another from a private window.

ninegua commented 3 years ago

The problem is fixed by creating identities stored in browser local storage.