Author Topic: DB question  (Read 1980 times)

tiggus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
DB question
« on: January 21, 2014, 11:43:58 PM »
If someone could please validate the model for the following would be appreciated, I'm still into beginning stages of TNet and having a hard time wrapping my head around the DB communication between client and host.  This is for a small online RPG, think less than 50 players at a time who can only load 1 room in the game at a time each.

My setup is as follows:

1) Lobby server and Game host both sit on a VPS.  Game host client connects and registers a server on Lobby, no one else can register a channel.
2) Other clients(players) connect to lobby to join the one server.
3) Game host has a sqlite DB with all player data/game data that needs to be stored persistently.  Only the host client should be able to update this DB directly.
4) Player clients also have a sqlite DB but it is a subset only containing non-sensitive data such as room/map information, items, etc.
5) The sqlite DB on client needs to be updated periodically from server DB, ie lets say via sequence numbers for objects or rows that should match

Question of the day is:  Is this entirely crazy or does this sound ok?  The idea being if I arrange it this way I only maintain one project which handles both my server and client code, making liberal use of .isHost checks.  I am a bit confused however on how I pass DB info from the host to the clients since I can't instantiate a object which relies on data that resides on a remote sqlite DB.

If possible was hoping not to hardcode the DB middleware logic into the server itself and keep it all in Unity for ease of development.

Sorry this got a bit wordy!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: DB question
« Reply #1 on: January 22, 2014, 05:50:18 AM »
I wouldn't use databases on the client side. Get whatever you need from the server, and keep it in memory. Running a DB is overkill. Even on the server side it's somewhat questionable.

Also keep in mind TNet uses authoritative players. The server doesn't store any DB info on it. All persistent data is still sent via RFCs.

tiggus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: DB question
« Reply #2 on: January 22, 2014, 09:48:05 AM »
Well the idea was originally that the player could also play the game in single player mode, so having a copy of the DB would allow them to progress while offline using local player data(think diablo single/multi options).

Then the question I started mulling over was how to sync that DB, but you are right it is probably overkill for the scope of this project.