Class SampSender


  • public class SampSender
    extends java.lang.Object
    Takes care of sending SAMP messages from activation methods.

    It does a similar job to its predecessor SendManager, which it cannibalises, but unlike that class it provides support for synchronous message sending (call/callAll), with result strings handed back to the calling code rather than just discarded or pushed through the logging system.

    Since:
    27 Mar 2018
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      SampSender​(java.lang.String mtype)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Outcome activateMessage​(java.util.Map<?,​?> message)
      Invoked to perform an activation action which involves sending a SAMP message to this sender's currently selected target client(s).
      javax.swing.ListModel<org.astrogrid.samp.Client> getClientListModel()
      Returns a list of the clients that are current possible targets for this sender's messages (subscribed to the relevant MType).
      javax.swing.ComboBoxModel<java.lang.Object> getClientSelectionModel()
      Returns a ComboBoxModel listing clients that are subscribed to this sender's MType.
      org.astrogrid.samp.gui.GuiHubConnector getConnector()
      Returns this sender's hub connector.
      TopcatSampControl getSampControl()
      Returns this sender's Samp control.
      java.lang.String getUnavailableText()
      Returns a message explaining why this sender can't do any useful work at the moment.
      boolean isAvailable()
      Indicates whether this sender has a chance of working.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SampSender

        public SampSender​(java.lang.String mtype)
        Constructor. The supplied MType determines what the offered list of recipient clients will contain.
        Parameters:
        mtype - message type to which this sender is sensitive
    • Method Detail

      • isAvailable

        public boolean isAvailable()
        Indicates whether this sender has a chance of working.
        Returns:
        false if this will never work
      • getClientListModel

        public javax.swing.ListModel<org.astrogrid.samp.Client> getClientListModel()
        Returns a list of the clients that are current possible targets for this sender's messages (subscribed to the relevant MType). If this list is empty, then the sender can't currently do any useful work.
        Returns:
        listmodel containing appropriately-subscribed clients
      • getClientSelectionModel

        public javax.swing.ComboBoxModel<java.lang.Object> getClientSelectionModel()
        Returns a ComboBoxModel listing clients that are subscribed to this sender's MType. It may also contain an object representing broadcast.
        Returns:
        client selection list
      • getSampControl

        public TopcatSampControl getSampControl()
        Returns this sender's Samp control.
        Returns:
        samp control object
      • getConnector

        public org.astrogrid.samp.gui.GuiHubConnector getConnector()
        Returns this sender's hub connector.
        Returns:
        connector object
      • activateMessage

        public Outcome activateMessage​(java.util.Map<?,​?> message)
        Invoked to perform an activation action which involves sending a SAMP message to this sender's currently selected target client(s).
        Parameters:
        message - message to send
        Returns:
        outcome
      • getUnavailableText

        public java.lang.String getUnavailableText()
        Returns a message explaining why this sender can't do any useful work at the moment. If it can, null is returned.
        Returns:
        unavailablity message, or null if all is working