Class ChatAgent

java.lang.Object
jadex.micro.tutorial.a6.ChatAgent
All Implemented Interfaces:
IChatGuiService, IChatService

public class ChatAgent extends Object implements IChatService, IChatGuiService
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 Details

    • agent

      protected jadex.core.IComponent agent
      The underlying micro agent.
    • chatservices

      protected Set<IChatService> chatservices
    • subscribers

      protected Set<jadex.future.SubscriptionIntermediateFuture<String>> subscribers
  • Constructor Details

    • ChatAgent

      public ChatAgent()
  • Method Details

    • onStart

      protected void onStart()
    • message

      public void message(String sender, String text)
      Receives a chat message.
      Specified by:
      message in interface IChatService
      Parameters:
      sender - The sender's name.
      text - The message text.
    • sendMessageToAll

      public void sendMessageToAll(String text)
      Send a message to all chat services;
      Specified by:
      sendMessageToAll in interface IChatGuiService
      Parameters:
      text - The text.
    • getName

      public jadex.future.IFuture<String> getName()
      Get the name of the chatter.
      Specified by:
      getName in interface IChatGuiService
      Returns:
      The name.
    • subscribeToChat

      public jadex.future.ISubscriptionIntermediateFuture<String> subscribeToChat()
      Subscribe to chat.
      Specified by:
      subscribeToChat in interface IChatGuiService
      Returns:
      Chat events.
    • getChatServices

      public Set<IChatService> getChatServices()
      Get the chat services.
      Returns:
      The chat services.
    • openInBrowser

      protected void openInBrowser(String url)
      Open the url in the browser.
      Parameters:
      url - The url.
    • main

      public static void main(String[] args) throws InterruptedException
      Start the example.
      Throws:
      InterruptedException