Commit 0172adf9 authored by Thibaut Démare's avatar Thibaut Démare

Add the 'close' command

parent cf900f40
...@@ -43,7 +43,13 @@ global { ...@@ -43,7 +43,13 @@ global {
gs_step gs_sender_id:"test1" gs_step_number:1; gs_step gs_sender_id:"test1" gs_step_number:1;
// Clear // Clear
//gs_clear gs_sender_id:"test1"; gs_clear gs_sender_id:"test1";
// Close
gs_close gs_sender_id:"test1";
// If the previous command has worked, the next one should work too
gs_add_sender gs_host:"localhost" gs_port:2001 gs_sender_id:"test1";
} }
} }
......
...@@ -12,6 +12,7 @@ public class IKeywordGSAdditional implements IKeyword { ...@@ -12,6 +12,7 @@ public class IKeywordGSAdditional implements IKeyword {
public static final String ADD_SENDER = "gs_add_sender"; public static final String ADD_SENDER = "gs_add_sender";
public static final String CLEAR = "gs_clear"; public static final String CLEAR = "gs_clear";
public static final String CLEAR_SENDERS = "gs_clear_senders"; public static final String CLEAR_SENDERS = "gs_clear_senders";
public static final String CLOSE = "gs_close";
public static final String REMOVE_EDGE = "gs_remove_edge"; public static final String REMOVE_EDGE = "gs_remove_edge";
public static final String REMOVE_EDGE_ATTRIBUTE = "gs_remove_edge_attribute"; public static final String REMOVE_EDGE_ATTRIBUTE = "gs_remove_edge_attribute";
public static final String REMOVE_NODE = "gs_remove_node"; public static final String REMOVE_NODE = "gs_remove_node";
......
package org.graphstream.gama.extension.sender;
import msi.gama.precompiler.ISymbolKind;
import msi.gama.precompiler.GamlAnnotations.facet;
import msi.gama.precompiler.GamlAnnotations.facets;
import msi.gama.precompiler.GamlAnnotations.inside;
import msi.gama.precompiler.GamlAnnotations.symbol;
import msi.gama.runtime.IScope;
import msi.gama.runtime.exceptions.GamaRuntimeException;
import msi.gaml.descriptions.IDescription;
import msi.gaml.expressions.IExpression;
import msi.gaml.statements.AbstractStatement;
import msi.gaml.statements.IStatement;
import msi.gaml.types.IType;
import org.graphstream.gama.extension.GSManager;
import org.graphstream.gama.extension.IKeywordGSAdditional;
@symbol(name = IKeywordGSAdditional.CLOSE, kind = ISymbolKind.SINGLE_STATEMENT, with_sequence = false)
@inside(kinds = { ISymbolKind.BEHAVIOR, ISymbolKind.SINGLE_STATEMENT })
@facets(value = { @facet(name = IKeywordGSAdditional.SENDERID, type = IType.STRING, optional = false)})
public class CloseStatement extends AbstractStatement implements IStatement{
final IExpression senderid;
public CloseStatement(IDescription desc) {
super(desc);
senderid = getFacet(IKeywordGSAdditional.SENDERID);
}
@Override
protected Object privateExecuteIn(IScope scope) throws GamaRuntimeException {
String senderId = (String)(senderid.value(scope));
GSSender sender = GSManager.getSender(senderId);
sender.close();
return null;
}
}
\ 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