Ok, so I'm writing a messenger-like program for a (don't laugh) local loop
.
I realize that there are some "what-ifs" such as two people logging on with the same username in the same session, but that's not important now
I'll keep a table in some DBMS with the following information:
UserName
PortNumber
I already have three user-names registered.
PortNumber are currently null since none of the users online at the moment.
First, we get the server running to accept connections, a username must be provided when requesting the connection (no passwords for the sake of simplicity).
If the username is in the DB, get the port number from the incoming request and map it to the username in the DB , otherwise, reject connection.
Same for requesting to disconnect, look up the name, if it exists (it should, since I'm already connected), set the port back to NULL and close the connections/sockets.
I should be able to check the status of the user at any time by checking if the port number is null or not.
Does everything sound correct? Are there any tutorials out there that touch on this subject? Doesn't have to be in
Java, I just want to get the logic down and read on the more common pitfalls.