Commit 818f610c authored by Thibaut Démare's avatar Thibaut Démare

The close statement removes now the sender in the GSManager

parent bcc4d62a
...@@ -52,6 +52,14 @@ public class GSManager { ...@@ -52,6 +52,14 @@ public class GSManager {
return sender; return sender;
} }
public static GSSender removeSender(String senderId) throws GamaRuntimeException {
GSSender sender = senders.remove(senderId);
if (sender == null)
throw new RuntimeException("Sender \"" + senderId
+ "\" does not exist");
return sender;
}
public static void addSender(String senderId, String host, int port) throws GamaRuntimeException { public static void addSender(String senderId, String host, int port) throws GamaRuntimeException {
GSSender sender = senders.get(senderId); GSSender sender = senders.get(senderId);
if (sender != null) if (sender != null)
......
...@@ -40,7 +40,7 @@ public class CloseStatement extends AbstractStatement implements IStatement{ ...@@ -40,7 +40,7 @@ public class CloseStatement extends AbstractStatement implements IStatement{
@Override @Override
protected Object privateExecuteIn(IScope scope) throws GamaRuntimeException { protected Object privateExecuteIn(IScope scope) throws GamaRuntimeException {
String senderId = (String)(senderid.value(scope)); String senderId = (String)(senderid.value(scope));
GSSender sender = GSManager.getSender(senderId); GSSender sender = GSManager.removeSender(senderId);
sender.close(); sender.close();
return null; return null;
} }
......
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