Why a library? If you have remote Access to the Database you can send queries directly.
If you don’t have a static ip to activate remote access in your database, you can simply rent a shared webhosting which are cheap and make a simple page where you can send data via url parameters and the page adds your data to the db.
With C#, you can use
WebClient.DownloadString -> GET
WebClient.UploadValues -> POST/PUT (Prefer the overload using NameValueCollection, it is easier than concatenating the string yourself and converting to a bytes array, and avoids problems: https://msdn.microsoft.com/fr-fr/library/9w7b4fz7(v=vs.110).aspx)
That’s what I do in my game. I also use a token per client and other data to authentify and avoid (hopefully) cheating
When you say a token to avoid cheating what do you mean. Iv have come up with a anti cheat system myself. they would need to disassemble the code to find out how it was generated.
@Mattlekim: I use a token generated with a timestamp, user’s infos etc generated at each connection and valid for a period of time + some other things encrypted in it.
And for highscores, I compare the playtime vs the score, the timestamps between 2 deaths, etc.
Anyone can use a deobfuscator and decompiler such as a de4dot to look at your source code of your game, though it might not be as readable as the original source code. Security through obscurity is a bad policy.
A game should be considered just like a web browser; it communicates with a server which communicates with the database. Game <-> Server <-> Database
For the game / server, you can then either use simple HTTP post/get commands, or write your own application layer protocol using TCP / UDP transport protocols. Should probably use Lidgren if you decide to not use HTTP.
For the server / database, you should then use an existing object-relational mapping (ORM) framework instead of writing your own. One such library that is popular is Dapper. Another is Entity Framework by Microsoft.
Just went to your repository and clicked on the first file (LeaderboardServer.cs) to be confronted by “bad words”… not that many, but the last one doesn’t have a “c” in it.
Fixed this in development branch as well as rewrote how it decodes the data from html tables. It now has the ability to download any MySQL database to a c# dictionary. Will finish the code and add the documentation soon and then merge with master brance