I'm working on a client/server based game. For the client I'm using Ionic Vue + Capacitor and for the server Python (with FastAPI and sqlalchemy).
On the server I've a table (model) called Player that looks like this:
class Game(Base):
__tablename__ = 'games'
id = Column(Integer, primary_key=True)
title = Column(String, nullable=False)
players = relationship("Player", secondary="game_to_player", back_populates='games')
class Player(Base):
__tablename__ = 'players'
id = Column(sqlUUID(as_uuid=True), primary_key=True, default=uuid4)
sid = Column(String, unique=True)
online = Column(Boolean, default=False)
phone_number = Column(String, unique=True)
name = Column(String)
games = relationship("Game", secondary="game_to_player", back_populates='players')
A record for this table is created upon the 1st ever connection from the client (get_or_create) approach where the PK is the phone's UUID. This part works fine, but there's a part where (in the client side) a new "game opener" starts a new game and is able to choose (from a list of contacts) the players he wants to play with.
This is the part where I'm not sure what to do:
How can I correlate the two together (i.e. How can the server "know" which players I want to invite the game)?
The only thing I thought I can use is the phone number, but while (in client) I can access all of my contacts phone number, I cannot get my own phone number (no Capacitor plugin for that - saw some Cordova plugins but I'm not sure if they're relevant as they're very old)
I'm pretty much I'm not inventing the wheel here and probably my approach is wrong. Maybe it shouldn't go through the server at all?
Any help will be appreciated.