I am not really experienced in that, so I might be wrong, however I am fairly experienced programmer (not pro, just experienced - at least in my own thinking), and I am thinking about those solutions, depending on preference, and the game itself:
I like to store data in XML. LINQ to XML makes it sweet and easy. And also it’s then easy to look into it and edit if needed.
Also, there’s binary serialization. Ofc, BinaryFormatter is slow and makes big files, but I never ran into need to make own serialization yet.
Sometimes I use external database with access through PHP. Not perfect, but again, I never needed it more than just prototyping.
And if you don’t want to register users in normal manner, you can always go with ‘random’ ID. Just don’t make it truly random - either use auto-increasing on server side, or use hashes, like MD5 hash of current System.DateTime or something.
About how to give it - if you generate it server-side (which imo would be recommended, but ofc it depends on your needs) - client sends generation request, server generates, and sends back the ID.
If client generates - simply generate and send to server.
Either way, both client and server would store it - server probably in files, while client could go with playerprefs or something. Again, depends on your needs.
Then server could load the info into class or whatever you like, every time that client starts and sends it’s ID. Then you could lookup data for that client using LINQ.
I’ll give example of my (prototype) way to store currently connected clients:
namespace SpaceGame
{
public sealed class Player
{
public readonly int ID;
public readonly NetworkConnection Connection;
public readonly int AuthCode;
public bool RespawnAllowed { get; set; }
public string Name { get; set; }
public Player(NetworkConnection connection, string name)
{
this.ID = connection.connectionId;
this.Connection = connection;
this.Name = name;
this.AuthCode = GenerateAuthCode();
}
public Player(NetworkConnection connection)
: this(connection, null) { }
private int GenerateAuthCode()
{
return (DateTime.Now.ToString() + ID.ToString() + Connection.address).GetHashCode();
}
}
public class PlayerCollection : HashSet<Player>
{
public Player Find(NetworkConnection conn)
{
return this.Where((p) => (p.Connection == conn)).FirstOrDefault();
}
public Player Find(int id)
{
return this.Where((p) => (p.ID == id)).FirstOrDefault();
}
public Player Find(string name)
{
return this.Where((p) => (p.Name == name)).FirstOrDefault();
}
public IEnumerable<Player> FindAll(string name)
{
return this.Where((p) => (p.Name == name));
}
public IEnumerable<Player> FilterNameContains(string name)
{
string lName = name.ToLower();
return this.Where((p) => (p.Name.ToLower().Contains(lName)));
}
public IEnumerable<Player> FilterNameStartsWith(string name)
{
string lName = name.ToLower();
return this.Where((p) => (p.Name.ToLower().StartsWith(lName)));
}
}
}
Ofc, as said, I am not that experienced in networking solutions, I more like have ideas and some general programming knowledge. So others might give you different solutions, etc.
But I like sharing knowledge if someone wants to learn. 