chess icon indicating copy to clipboard operation
chess copied to clipboard

Add basic Guest play support

Open N4r35h opened this issue 1 year ago • 9 comments

basic_guest_chess.webm

just a very basic implementation that gets guest play working

  • guest vs guest (no db saves)
  • user vs guest (no db saves)
  • user vs user

if game contains a guest we wont save to the database this is because the guest is not a valid db user we might make a default user for that and save so in case of user vs guest scenario we can show the user his history (if shown in the future)

this is meant to kick things off

please share your inputs on this @hkirat and others

resolves #106

N4r35h avatar Apr 20 '24 10:04 N4r35h

@hkirat if both players are a guest no need to persist to db right ? it really serves no purpose can we have this merged and take up persisting in another pr ? this at-least gets guest play kick started

if any one user is guest can we just point that to a "Default precreated guest user" ? also please explain more on what we will perform saving the guests

share your thoughts

N4r35h avatar Apr 20 '24 16:04 N4r35h

@hkirat if both players are a guest no need to persist to db right ? it really serves no purpose can we have this merged and take up persisting in another pr ? this at-least gets guest play kick started

if any one user is guest can we just point that to a "Default precreated guest user" ? also please explain more on what we will perform saving the guests

share your thoughts

I think it's mostly needed, because you want to recover the game, if the user get's disconnected by mistake/internet issue, or refreshes etc.

nimit9 avatar Apr 20 '24 16:04 nimit9

we also need to allow them to share their games and replay it

hkirat avatar Apr 20 '24 19:04 hkirat

We can just add guests in the User table for now with type set to guest

hkirat avatar Apr 20 '24 19:04 hkirat

@N4r35h let me know if u'd like to pursue this further, if not I'll merge some parts of this and finish the rest

hkirat avatar Apr 20 '24 20:04 hkirat

@N4r35h let me know if u'd like to pursue this further, if not I'll merge some parts of this and finish the rest

@hkirat I would like to pursue this just a few confirmations

Even if both players are guest we want to store to db ? We will have a user entry for each guest ?

N4r35h avatar Apr 20 '24 22:04 N4r35h

@hkirat now we save guests to the database and persist the games

We can just add guests in the User table for now with type set to guest

have a look and if it looks good merge it in

guest sessions are done via a separate jwt in a cookie called guest so if a guest refreshes the page or for example looses internet connection for a few seconds he can still rejoin and play

let me know if this seperate cookie route would be ok or if we have to hack it into the passport.js way not sure if that would be possible maybe with some weird custom logic like a GuestAuthProvider idk

below is a recording that showcases the guest session persistence so they can rejoin the match

guest_session_persistance.webm

N4r35h avatar Apr 21 '24 07:04 N4r35h

@hkirat made the requested changes please have a look now

N4r35h avatar Apr 21 '24 22:04 N4r35h

@hkirat should be good to merge, resolved conflicts

N4r35h avatar May 04 '24 04:05 N4r35h

@hkirat could you please take a look at this PR ?

N4r35h avatar Jun 04 '24 04:06 N4r35h

@hkirat any bounty for this ?

N4r35h avatar Jul 10 '24 17:07 N4r35h