Commit 75eaf520 authored by legoc's avatar legoc
Browse files

Updated SessionManager: login with user and loginRefused method

parent 703d5aa3
......@@ -98,6 +98,10 @@ public class SessionManager {
}
public void login(boolean standAlone) throws ClientAlreadyLaunchedException {
login(standAlone, null);
}
public void login(boolean standAlone, String user) throws ClientAlreadyLaunchedException {
// Create the message type.
SessionRequests.Message type = SessionRequests.Message.newBuilder()
......@@ -105,9 +109,19 @@ public class SessionManager {
.build();
// Create the request.
SessionRequests.LoginRequest request = SessionRequests.LoginRequest.newBuilder()
.setStandAlone(standAlone)
.build();
SessionRequests.LoginRequest request;
if (user != null) {
request = SessionRequests.LoginRequest.newBuilder()
.setStandAlone(standAlone)
.setUser(user)
.build();
}
else {
request = SessionRequests.LoginRequest.newBuilder()
.setStandAlone(standAlone)
.build();
}
sessionRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -128,6 +142,29 @@ public class SessionManager {
}
}
public void loginRefused(String user, String reason) {
// Create the message type.
SessionRequests.Message type = SessionRequests.Message.newBuilder()
.setType(SessionRequests.Message.Type.LoginRefused)
.build();
// Create the request.
SessionRequests.LoginRefusedRequest request = SessionRequests.LoginRefusedRequest.newBuilder()
.setUser(user)
.setReason(reason)
.build();
sessionRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse.parseFrom(sessionRequester.receive());
}
catch (InvalidProtocolBufferException e) {
System.err.println("error in parsing response of loginRefused");
}
}
public void enableRemoteControl(String clientType) {
// Create the message type.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment