Package org.zeromq

Class ZAgent.SimpleAgent

java.lang.Object
org.zeromq.ZAgent.SimpleAgent
All Implemented Interfaces:
ZAgent
Enclosing interface:
ZAgent

public static final class ZAgent.SimpleAgent extends Object implements ZAgent
Creates a very simple agent with an easy lock mechanism.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.zeromq.ZAgent

    ZAgent.Creator, ZAgent.SelectorCreator, ZAgent.SimpleAgent
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final byte[]
     
    private boolean
     
    private final ZMQ.Socket
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new simple agent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the pipe.
    Returns the socket used for communication.
    Receives a control message sent from the Plateau in the Corbeille.
    recv(boolean wait)
    Receives a control message sent from the Plateau in the Corbeille.
    recv(int timeout)
    Receives a control message sent from the Plateau in the Corbeille.
    boolean
    send(String word)
    Sends a control message from the Corbeille to the Plateau side.
    boolean
    send(String word, boolean more)
    Sends a control message from the Corbeille to the Plateau side.
    boolean
    send(ZMsg message)
    Sends a control message from the Corbeille to the Plateau.
    boolean
    send(ZMsg msg, boolean destroy)
    Sends a control message from Corbeille side to the Plateau side.
    boolean
    Gives a sign if the distant Star is here.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pipe

      private final ZMQ.Socket pipe
    • lock

      private final byte[] lock
    • locked

      private boolean locked
  • Constructor Details

    • SimpleAgent

      public SimpleAgent(ZMQ.Socket pipe, String lock)
      Creates a new simple agent.
      Parameters:
      pipe - the pipe used to send control messages to the distant IStar.
      lock - the lock to use. If null, the locking mechanism is omitted.
  • Method Details

    • sign

      public boolean sign()
      Description copied from interface: ZAgent
      Gives a sign if the distant Star is here.
      Specified by:
      sign in interface ZAgent
      Returns:
      true if here, otherwise false
    • close

      public void close()
      Description copied from interface: ZAgent
      Closes the pipe.
      Specified by:
      close in interface ZAgent
    • recv

      public ZMsg recv()
      Description copied from interface: ZAgent
      Receives a control message sent from the Plateau in the Corbeille. The call is blocking.
      Specified by:
      recv in interface ZAgent
      Returns:
      the received message or null if the context was shut down.
    • recv

      public ZMsg recv(int timeout)
      Description copied from interface: ZAgent
      Receives a control message sent from the Plateau in the Corbeille. The call times out if there is no message after the elapsed time.
      Specified by:
      recv in interface ZAgent
      Parameters:
      timeout - the timeout in milliseconds before returning null.
      Returns:
      the received message or null if the context was shut down or if no message after the timeout.
    • recv

      public ZMsg recv(boolean wait)
      Description copied from interface: ZAgent
      Receives a control message sent from the Plateau in the Corbeille. The call is blocking depending on the parameter.
      Specified by:
      recv in interface ZAgent
      Parameters:
      wait - true to make a blocking call, false to not wait, and possibly return null
      Returns:
      the received message or null if the context was shut down or if there is no message when not blocking.
    • send

      public boolean send(ZMsg message)
      Description copied from interface: ZAgent
      Sends a control message from the Corbeille to the Plateau.
      Specified by:
      send in interface ZAgent
      Parameters:
      message - the message to send
      Returns:
      true if the message was sent, otherwise false (if the distant Star is dead for example)
    • send

      public boolean send(String word)
      Description copied from interface: ZAgent
      Sends a control message from the Corbeille to the Plateau side.
      Specified by:
      send in interface ZAgent
      Parameters:
      word - the message to send
      Returns:
      true if the message was sent, otherwise false (if the distant Star is dead for example)
    • send

      public boolean send(String word, boolean more)
      Description copied from interface: ZAgent
      Sends a control message from the Corbeille to the Plateau side.
      Specified by:
      send in interface ZAgent
      Parameters:
      word - the message to send
      more - true to send more strings in a single message
      Returns:
      true if the message was sent, otherwise false (if the distant Star is dead for example)
    • send

      public boolean send(ZMsg msg, boolean destroy)
      Description copied from interface: ZAgent
      Sends a control message from Corbeille side to the Plateau side.
      Specified by:
      send in interface ZAgent
      Parameters:
      msg - the message to send
      destroy - true to destroy the message after sending it.
      Returns:
      true if the message was sent, otherwise false (if the distant Star is dead for example)
    • pipe

      public ZMQ.Socket pipe()
      Description copied from interface: ZAgent
      Returns the socket used for communication. For advanced usage.
      Specified by:
      pipe in interface ZAgent
      Returns:
      the socket used to communicate with the distant Star.