I'm currently working on a school project that aims at creating a P2P chat client for users on the same network. For now, it will only be used by users on the same LAN network. But hopefully,I will to extend to work for users on the same public Wifi(if that's possible, is it?).What is confusing me at the moment is how to store users information like username, password, account picture, message history...etc. I was thinking of creating a database and storing them there but that seems inconvenient and since the app won't connect to some sort of server it might affect portability. So what is a convenient way of storing user info? Thanks in advance.
-
1Is authentication a requirement of the project? If so I don't see how it can be a pure P2P setup, you'll need an authentication server. If not, don't worry about username/password, just store the display name and the other stuff on the client, send it to other clients when they request it and cache it there (for large things like a picture that you don't want to send with every message).– HeyJan 28, 2015 at 17:09
-
Can you suggest some specific ways to cache the data in C#?– xabushJan 28, 2015 at 17:34
-
If you decide to go with sqlite you could just stick everything in there. Retrieving blobs from sqlite should be faster than using separate files for small, compressed images.– HeyJan 28, 2015 at 19:46
-
You could look at "local storage", introduced in HTML5 ... diveintohtml5.info/storage.html– Mawg says reinstate MonicaJan 29, 2015 at 14:38
2 Answers
It's pretty common to store stuff you want in a database, on a client, in something like sqlite. It's a database that is pretty lite, and very common for desktop apps.
-
I haven't used sqlite before...does it need server setup like other databases(I mostly use MySQL) and how about when distributing the app to other people for installation?– xabushJan 28, 2015 at 17:22
-
@avidProgrammer it doesn't, the database just lives in a file, and the RDBMS is embedded in the program.– HeyJan 28, 2015 at 17:27
You will want to store the users data locally. And as people come online they broadcast their information. If the local client needs to update your friends profile information it can do so then.
As for storing the information locally here are a two options:
- text file although not generally recommended for normal production deployment but does work for smaller proof-of-concept type projects such as yours.
- HSQLDB is a what I often turn to as a quick alternative. No install needed. surprisingly powerful.