Conversation
…ge the users database, small bugfixes on the DatabaseManager
| */ | ||
|
|
||
| /*Questions I have | ||
| - why do we do ByteString.copyFrom instead of just converting to bytestring directly |
There was a problem hiding this comment.
If possible, switch to doing <proto>.toByteString(), may cut out a needless copy (unsure if it is doing that)
| - why do we do ByteString.copyFrom instead of just converting to bytestring directly | ||
| - ChannelActive is called twice when I run my testing client | ||
| - The things the client sends are only handled by one instance, so it is not *Currently* a problem | ||
| - Why does this happen? |
There was a problem hiding this comment.
Requires investigation from where netty is creating the ServerHandler (Server.java)
| private String selfName = ""; | ||
| private MessageManager mgr = new MessageManager(); | ||
| private MessageManager msgmgr = new MessageManager(); | ||
| private DatabaseHandler dbmgr = new DatabaseHandler("Users.db"); //Can change where the database is stored later |
There was a problem hiding this comment.
if not already present, add *.db to gitignore to be safe
There was a problem hiding this comment.
Is a case by case thing? Or can you configure git to ignore all.db files? I did not push the database itself.
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public class SessionData { |
There was a problem hiding this comment.
This class needs threadsafety
There was a problem hiding this comment.
Added a synchronized tag to addClientUser. Resolved, maybe
| .setType(Control.ServerMessageType.SESSION_REJECTED) | ||
| .setSuccess(false) | ||
| .build(); | ||
| sendProto(ByteString.copyFrom(reply.toByteArray()), General.FvPacketType.SERVER_MESSAGE); |
There was a problem hiding this comment.
This is sending the "rejected" message back to the prospective host, not the person who requested.
| .setType(Control.ServerMessageType.SESSION_STARTING) | ||
| .setSuccess(true) | ||
| .build(); | ||
| sendProto(ByteString.copyFrom(reply.toByteArray()), General.FvPacketType.SERVER_MESSAGE, UsersData.getUser(sr.getName())); |
There was a problem hiding this comment.
In the case of a "race condition" here, do some error checking to ensure that the requester still exists.
There was a problem hiding this comment.
What is the race condition here? I'm not sure I understand. I added a check at the beginning of the method to ensure that the "client" still exists by the time the server receives the host's response packet.
Resolved (maybe).
There was a problem hiding this comment.
that check should resolve it, race condition in quotes meant it was an instance where an unexpected change occurred under your nose
| .setType(Control.ServerMessageType.SESSION_STARTING) | ||
| .setSuccess(true) | ||
| .build(); | ||
| sendProto(ByteString.copyFrom(reply.toByteArray()), General.FvPacketType.SERVER_MESSAGE, UsersData.getUser(sr.getName())); |
There was a problem hiding this comment.
See comment from L209
There was a problem hiding this comment.
See above. Resolved (maybe)
No description provided.