Commit 22319fc7 authored by helene ortiz's avatar helene ortiz
Browse files

add method getSender

parent c1e4efeb
......@@ -22,6 +22,7 @@ import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.bridge.events.TokenEvent;
import fr.ill.ics.bridge.events.TokenEvent.TokenServerState;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
import fr.ill.ics.util.ConfigManager;
/**
*
......@@ -53,11 +54,12 @@ public class TokenManager {
public void freeToken() {
SessionManager.getInstance(SERVER_ID).releaseToken("USER");
SessionManager.getInstance(SERVER_ID).releaseToken(SessionManager.getInstance(SERVER_ID).getSender());
}
public void askForToken(String clientType) {
SessionManager.getInstance(SERVER_ID).requestToken(clientType, "USER");
SessionManager.getInstance(SERVER_ID).requestToken(clientType, SessionManager.getInstance(SERVER_ID).getSender());
}
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ import fr.ill.ics.cameo.RequesterCreationException;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.session.SessionRequests;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
import fr.ill.ics.util.ConfigManager;
public class SessionManager {
......@@ -42,6 +43,9 @@ public class SessionManager {
private String password;
private String instrumentName;
private String sender = null;
private static Map<String, SessionManager> instances = new HashMap<String, SessionManager>();
public class ClientAlreadyLaunchedException extends Exception {};
......@@ -329,4 +333,17 @@ public class SessionManager {
public String getUserName() {
return userName;
}
public String getSender() {
if (sender == null) {
if (ConfigManager.getInstance().isRemoteClient()) {
sender = getUserName();
} else {
sender = getInstrumentName();
}
}
return sender;
}
}
\ 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