Example 11 - Working in Remote Workspaces Agents can join workspaces that are hosted on remote nodes, by means of a joinRemoteWorkspace action (provided by the NodeArtifact. As soon as the join succeed, the interaction within remote workspaces is the same as local workspace. In the following example, a Jason agent joins the default workspace of a CArtAgO node running on localhost. The following Java program installs a CArtAgO node on localhost, to make it reachable (also) by remote agents:
package examples;

import cartago.*;
import cartago.util.BasicLogger;

public class Ex00a_HelloRemoteWorld {
	
  public static void main(String[] args) throws Exception {			
    CartagoService.startNode();
    CartagoService.installInfrastructureLayer("default");
    CartagoService.startInfrastructureService("default");
    CartagoService.registerLogger("default",new BasicLogger());  
    System.out.println("CArtAgO Node Ready.");
  }
}
Highlights: % Then, it follows the Jason program which creates a standalone CArtAgO node with a single agent:
MAS example11_remote {

  environment: 
  c4jason.CartagoEnvironment

  agents:  
  voyager agentArchClass c4jason.CAgentArch;

  classpath: "../../../lib/cartago.jar";"../../../lib/c4jason.jar";    
}
The voyager agent boots in the standalone node, then it joins a remote workspace, where he creates and uses an artifact.
!test_remote.

+!test_remote 
  <- ?current_wsp(Id,_,_);
     +default_wsp(Id);
     println("testing remote..");
     joinRemoteWorkspace("default","localhost",WspID2);
     ?current_wsp(_,WName,_);
     println("hello there ",WName);
     !use_remote;
     quitWorkspace.
      
+!use_remote 
  <- makeArtifact("c0","examples.Counter",[],Id);
     focus(Id);
     inc;
     inc.

+count(V) 
  <- ?default_wsp(Id);
     println("count changed: ",V)[wsp_id(Id)].
  
-!use_remote [makeArtifactFailure("artifact_already_present",_)]
  <- ?default_wsp(WId);
     println("artifact already created ")[wsp_id(WId)];
     lookupArtifact("c0",Id);
     focus(Id);
     inc.   
Highlights: