Commit 7e71f3a9 authored by legoc's avatar legoc

Added client id from login response

parent 296ec324
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
......
......@@ -35,12 +35,14 @@ import fr.ill.ics.nomadserver.commandzone.CommandZoneRequests;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.common.Common.Error.Type;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
public class CommandZoneAccessor {
private static final Logger LOGGER = Logger.getLogger(CommandZoneAccessor.class.getName());
private String serverId;
private int clientId;
private Application.Requester commandBoxRequester;
private Map<Integer, Boolean> commandConflicts = new HashMap<Integer, Boolean>();
......@@ -131,6 +133,9 @@ public class CommandZoneAccessor {
public void init() {
// Get the client id.
clientId = SessionManager.getInstance(serverId).getClientId();
// Connect nomad server.
Application.Instance nomad = ServerInstance.getInstance().getApplicationInstance(serverId);
......
......@@ -35,6 +35,7 @@ public class SessionManager {
private String serverId;
private Application.Requester sessionRequester;
private boolean allOk;
private int clientId = 0;
private static Map<String, SessionManager> instances = new HashMap<String, SessionManager>();
......@@ -106,14 +107,19 @@ public class SessionManager {
sessionRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse response = Common.BooleanResponse.parseFrom(sessionRequester.receive());
Common.Int32Response response = Common.Int32Response.parseFrom(sessionRequester.receive());
if (response.hasError()) {
throw new ClientAlreadyLaunchedException();
}
// Get the client id.
clientId = response.getValue();
System.out.println("Client id is " + response.getValue());
}
catch (InvalidProtocolBufferException e) {
System.err.println("error in parsing response of executeCommand");
System.err.println("error in parsing response of login");
}
}
......@@ -121,4 +127,7 @@ public class SessionManager {
return allOk;
}
public int getClientId() {
return clientId;
}
}
\ No newline at end of file
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