Package madkit.message.hook

# Class HookMessage

java.lang.Object
madkit.kernel.Message
madkit.message.ObjectMessage<HookMessage.AgentActionEvent>
madkit.message.hook.HookMessage

All Implemented Interfaces:
  `Serializable`, `Cloneable`

Direct Known Subclasses:
  `AgentLifeEvent`, `CGREvent`

public class HookMessage extends ObjectMessage<HookMessage.AgentActionEvent>
This message could be used to request a kernel's hook on agent actions so that the sender will be kept informed when an agent performed particular action.

Since:
  MaDKit 5.0.0.14
Version:
  0.91
Author:
  Fabien Michel
See Also:
  - `HookMessage.AgentActionEvent`
  - Serialized Form

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `HookMessage.AgentActionEvent`
  Enumeration representing agent actions that could be monitored using hooks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HookMessage(HookMessage.AgentActionEvent hookType)`
  This message should be used to request or release a hook on an agent action.

- ## Method Summary

  ### Methods inherited from class madkit.message.ObjectMessage

  `getContent, max, min, sort, toString`

  ### Methods inherited from class madkit.kernel.Message

  `clone, getConversationID, getReceiver, getSender`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### HookMessage

    public HookMessage(HookMessage.AgentActionEvent hookType)
    This message should be used to request or release a hook on an agent action. The message should be sent to the kernel (which is the manager of the SYSTEM group in the local community), here is an example :

         sendMessage(
                LocalCommunity.NAME,
                LocalCommunity.Groups.SYSTEM,
                Organization.GROUP_MANAGER_ROLE,
                new HookMessage(AgentActionEvent.REQUEST_ROLE));

    In this example, the sender will be informed by the kernel of all successful requestRole operation made by the agents. This information will be transmitted using a subclass of HookMessage depending on the nature of the event. That is, `OrganizationEvent`, `MessageEvent` or `AgentLifeEvent` messages will be sent by the kernel according to the type of the hook which has been requested.

    To give up the hook, just send to the kernel another message built with the same action and it will remove the sender from the subscriber list.

    Parameters:
      `hookType` - the action event type to monitor
    See Also:
      - `HookMessage.AgentActionEvent`