Package jadex.micro.tutorial.a6
Class ChatAgent
java.lang.Object
jadex.micro.tutorial.a6.ChatAgent
- All Implemented Interfaces:
IChatGuiService
,IChatService
Chat micro agent provides a basic chat service and publishes it as rest web service.
Additionally, in this example the agent provides a minimal web user interface to
send chat messages and show all received messages.
- The agent uses IChatService to send messages to other agents
- The agent uses IChatGuiService to talk to the UI
- The UI subscribes to the IChatGuiService to receive chat messages (and other notifications)
- The UI uses sendMessageToAll of IChatGuiService to tell its agent to send the chat message to the other agents
- The agent publishes the UI via its folder and the contained index.html page on the web server
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jadex.core.IComponent
The underlying micro agent.protected Set
<IChatService> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the chat services.jadex.future.IFuture
<String> getName()
Get the name of the chatter.static void
Start the example.void
Receives a chat message.protected void
onStart()
protected void
openInBrowser
(String url) Open the url in the browser.void
sendMessageToAll
(String text) Send a message to all chat services;jadex.future.ISubscriptionIntermediateFuture
<String> Subscribe to chat.
-
Field Details
-
agent
protected jadex.core.IComponent agentThe underlying micro agent. -
chatservices
-
subscribers
-
-
Constructor Details
-
ChatAgent
public ChatAgent()
-
-
Method Details
-
onStart
protected void onStart() -
message
Receives a chat message.- Specified by:
message
in interfaceIChatService
- Parameters:
sender
- The sender's name.text
- The message text.
-
sendMessageToAll
Send a message to all chat services;- Specified by:
sendMessageToAll
in interfaceIChatGuiService
- Parameters:
text
- The text.
-
getName
Get the name of the chatter.- Specified by:
getName
in interfaceIChatGuiService
- Returns:
- The name.
-
subscribeToChat
Subscribe to chat.- Specified by:
subscribeToChat
in interfaceIChatGuiService
- Returns:
- Chat events.
-
getChatServices
Get the chat services.- Returns:
- The chat services.
-
openInBrowser
Open the url in the browser.- Parameters:
url
- The url.
-
main
Start the example.- Throws:
InterruptedException
-