3 Replies - 387 Views - Last Post: 31 July 2013 - 02:25 PM Rate Topic: -----

#1 jmanelson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 26-February 09

Client Server Database Confusion, Java

Posted 31 July 2013 - 10:54 AM

Not sure if this is topic belongs here or in the java category, but I am making a small game using LibGdx and my goal is for it will work on Windows and Android. The LibGdx game client is coming along well enough but I have some issues with multilayer/networking and databases.

I want it to be a turn based game and to be multilayer (1v1). I want to have a database to verify user (Username/Password login) and to keep statistics for the users. Ive been trying to read up on android and databases. From what I've found android only natively supports SQLite which is server-less.

I am using Kryonet for the server/client stuff and this is supposed to work on android.

My structure is:
-LibGdx Client
-Server (Kryonet)
- ????Database

I have yet to choose a database or libraries to work with one and I a bit lost. In my mind I think "cannot the android phone communicate with the server its request and the server will do all of the database interaction and give the information back to the android." this would eliminate the direct android -> database interaction meaning I could use any database I wanted. Am I way off on this architecture? Also which database would you guys recommend, mySQL, or a java based one like derby, or do I even need a database server and should i just use SQL lite and communicate with it using my server?

I have never done anything with a database (minus a class on office where we dabbled with access a few years ago but I don't remember any of that).

Also I have a kryonet question. I have no problems connecting the client to the server but in term of multilayer, but in terms of multilayer can the sever connect two clients together or does it have to manually relay packets from one to another? Would this mean I need a new server for each new game or can 1 server facilitate many games? This is all new territory for me.

I apologize for the multitude of questions in this post and appreciate any help.

Is This A Good Question/Topic? 0
  • +

Replies To: Client Server Database Confusion, Java

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8956
  • View blog
  • Posts: 33,581
  • Joined: 12-June 08

Re: Client Server Database Confusion, Java

Posted 31 July 2013 - 12:03 PM

Quote

I want it to be a turn based game and to be multilayer (1v1). I want to have a database to verify user (Username/Password login) and to keep statistics for the users. Ive been trying to read up on android and databases. From what I've found android only natively supports SQLite which is server-less.
[...]
I have yet to choose a database or libraries to work with one and I a bit lost. In my mind I think "cannot the android phone communicate with the server its request and the server will do all of the database interaction and give the information back to the android

So the SQLite is for local storage, right? That doesn't preclude you from using database server out there in the web! Pick your poison - MSSQL, MYSQL, etc... typically I just go with what ever I am provided by the hosting company I am using.

The gist is you have your host with your database on it. You would then create a webserivce or use REST as the entry point from your app to the database. See.. your app won't see the database like it would a local db because having your database out there, naked and exposed to the cruel winds of the internet make it a ripe target to exploit, change, destroy, hack, etc. That's why you use an intermediary like a web service or REST. Think of it like a door from the outside (internet) to your inside (db). A contained and controlled portal to push traffic through! I would recommend reading up on both REST and webservices to get a feel for which one would work best with you.



Quote

Also I have a kryonet question. I have no problems connecting the client to the server but in term of multilayer, but in terms of multilayer can the sever connect two clients together or does it have to manually relay packets from one to another
[...]
Would this mean I need a new server for each new game or can 1 server facilitate many games? This is all new territory for me.

I've never played with kryonet, but in general you would *NOT* want the players to connect to each other. Have the 'game state' on the server and the server act as the 'end all/be all' authority on what is the current state of the game. Having the clients with this responsibility leads to drift (the game states between clients get out of sync), exploitation, and what not.

When your clients send information to the server part of that information should include the game's unique id, the player's id, move, etc. I am not clear on how your game is setup, but that would be the 30k feet view.
Was This Post Helpful? 0
  • +
  • -

#3 jmanelson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 26-February 09

Re: Client Server Database Confusion, Java

Posted 31 July 2013 - 02:22 PM

Thanks modi,

From what I understand I will have the Server as the manager of the games (or game states) and processing the requests/relaying the info about state changes to the clients (for example submitting a turn or displaying the opponents actions after a turn is made).

As for the database I can also use the same server (or different one) as the bridge (or web service) that is connecting/making requests/retrieving the data for the clients to whatever database server I choose to go with.

I did some looking at REST and SOAP architectures and did not quite grasp the models just yet but I think as I am implementing these systems listed above I think they will make more sense and I can hopefully shape my interfaces to fit one of those models to one to gain its advantages.

so to clarify I will have:
the game clients (users)
my game server
database server (whatever it may be)

and the clients and database server both connect to the GameServer but not with each other directly.

Thanks again for the help, I am a Computer Science student but still *clearly* a novice at programming and as well as networking in general.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8956
  • View blog
  • Posts: 33,581
  • Joined: 12-June 08

Re: Client Server Database Confusion, Java

Posted 31 July 2013 - 02:25 PM

Pretty much - yeah.. that's the high level overview.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1