Package de.tuclausthal.informatik.winf.mobileagents.messaging

Examples of de.tuclausthal.informatik.winf.mobileagents.messaging.Message


      BasicAgentInfo recipient = (BasicAgentInfo)this.agentInfos.get(m.getRecipient());
     
      // no local address
      if(recipient == null)
      {
        Message m2 = MessagingManager.getInstance().createMessage();
        m2.setSender("local:"+HOST_ADDRESS);
        m2.setRecipient(m.getSender());
        m2.setBody("MESSAGESERVICE\nFAILED\n"+m.getMessageID()+"\nRECIPIENT UNKNOWN");
        m2.setRequiresReceipt(false);
        this.sendMessage(m2);
        return;     
      }
      try
      {
        recipient.getMessageList().addMessage(m);
      }
      catch (MessageListFullException e)
      {
        // could not append to message-list
        Message m2 = MessagingManager.getInstance().createMessage();
        m2.setSender("local:"+HOST_ADDRESS);
        m2.setRecipient(m.getSender());
        m2.setBody("MESSAGESERVICE\nFAILED\n"+m.getMessageID()+"\nMESSAGELIST FULL");
        m2.setRequiresReceipt(false);
      }
    }
   
    if(m.getRequiresReceipt())
    {
      Message receipt = MessagingManager.getInstance().createMessage();
      receipt.setSender("local:"+HOST_ADDRESS);
      receipt.setRecipient(m.getSender());
      receipt.setBody("MESSAGESERVICE\nSENT\n"+m.getMessageID());
      receipt.setRequiresReceipt(false);
     
      // no security check here:
      // we're host, so we may do everything
      this.sendMessage(receipt);
    }
View Full Code Here


  {
    while(!this.shouldAgentStop())
    {
      // wait for a message
      // method clears message so we don't need to delete it
      Message m = agentServices.waitForNextMessage();

      // m can be null, e.g. if we should quit
      if(m == null) continue;

      if(m.getBody().equals("EXIT"))
      {
        return;
      } else
      {
        // create a new message, agentService works as a factory for us
        Message echo = agentServices.createMessage();

        // set the recipient and the body
        echo.setRecipient(m.getRecipient());
        echo.setBody(m.getBody());

        // we do not want a receipt
        echo.setRequiresReceipt(false);

        // send message
        agentServices.sendMessage(echo);
      }
    }
View Full Code Here

   * @return former first message of this <code>MessageList</code>
   * @see de.tuclausthal.informatik.winf.mobileagents.messaging.MessageList#popFirstMessage
   */
  public Message popFirstMessage()
  {
    Message retval = this.getFirstMessage();
    this.removeMessage(retval);
    return retval;
  }
View Full Code Here

      public void start(AgentServices as)
      {
        System.out.println(new Date().toString());

        Message m = as.createMessage();
        m.setBody("Testnachricht");
        m.setRecipient("local:host");
        m.setRequiresReceipt(true);
        as.sendMessage(m);

        m = as.createMessage();
        m.setRecipient("local:" + this.getName());
        m.setBody("To Me");
        as.sendMessage(m);

        m = as.waitForNextMessage();
        System.out.println(
          "Message received: " + new String(m.getBody()));
        m = as.waitForNextMessage();
        System.out.println(
          "Message received: " + new String(m.getBody()));
      }

    });

    f.pack();
View Full Code Here

   * @return former last message of this <code>MessageList</code>
   * @see de.tuclausthal.informatik.winf.mobileagents.messaging.MessageList#popLastMessage
   */
  public Message popLastMessage()
  {
    Message retval = this.getLastMessage();
    this.removeMessage(retval);
    return retval;
  }
View Full Code Here

   * @return former i-th message of this <code>MessageList</code>
   * @see de.tuclausthal.informatik.winf.mobileagents.messaging.MessageList#popMessage(int)
   */
  public Message popMessage(int i)
  {
    Message retval = this.getMessage(i);
    this.removeMessage(retval);
    return retval;
  }
View Full Code Here

TOP

Related Classes of de.tuclausthal.informatik.winf.mobileagents.messaging.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.