or(p,q):p(true,q); not(p):p(false,true); users[10]:void; nbrusers:0; login(remotedict):: { nbrusers := nbrusers + 1; users[nbrusers] := remotedict; chatsend("User" + text(nbrusers) + " logged in") }; chatsend(message):: { for(i:1,or(not(is_void(users[i])), i < nbrusers), i:=i+1, {tmp : users[i]; tmp.chatreceive(message)} ) } |
chatreceive(message):display(message); a:remotedict("Master/server"); a->login(agentself); |
How does it work ?
First we start the Master Agent System. On this system we will load the Chatserver.
So you need to open the server.cborg in this agent system and then you need
to evaluate the entire document. You will get something like :
Fig 1.1 Master Agent System with Chatserver. |
Fig 1.2 Sub Agent System with Chatclient. |
a.chatsend("Your message here") |