Class ServerMessageReceiver

  • All Implemented Interfaces:
    ServerBidibMessageProcessor, org.bidib.jbidibc.core.BidibMessageProcessor, org.bidib.jbidibc.messages.MessageProcessor, org.bidib.jbidibc.messages.MessageReceiver

    public abstract class ServerMessageReceiver
    extends java.lang.Object
    implements ServerBidibMessageProcessor, org.bidib.jbidibc.messages.MessageReceiver
    This is the server message receiver. Message from the network client will be received and then forwarded to the JMRI BiDiB connection via the traffic controler.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) boolean escapeHot  
      protected java.util.concurrent.atomic.AtomicBoolean running  
      • Fields inherited from interface org.bidib.jbidibc.core.BidibMessageProcessor

        IGNORE_WRONG_MESSAGE_NUMBER
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addMessageListener​(org.bidib.jbidibc.core.MessageListener messageListener)  
      void addNodeListener​(org.bidib.jbidibc.core.NodeListener nodeListener)  
      void cleanup()  
      void disable()  
      void enable()  
      java.lang.String getErrorInformation()  
      void processMessages​(java.io.ByteArrayOutputStream output)  
      abstract void publishResponse​(java.io.ByteArrayOutputStream output)
      Publish the response in the provided byte array output stream.
      void receive​(java.io.ByteArrayOutputStream output)
      Process data received from network.
      void removeMessageListener​(org.bidib.jbidibc.core.MessageListener messageListener)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.bidib.jbidibc.core.BidibMessageProcessor

        removeNodeListener
    • Field Detail

      • running

        protected java.util.concurrent.atomic.AtomicBoolean running
    • Method Detail

      • receive

        public void receive​(java.io.ByteArrayOutputStream output)
        Process data received from network. Forward to BiDiB connection Currently we split possible multi-message packets into a sequence of single messages. TODO: forward multi-message packets, this would require that the BiDiB traffic controller supports this
        Specified by:
        receive in interface org.bidib.jbidibc.messages.MessageReceiver
        Parameters:
        output - data received
      • publishResponse

        public abstract void publishResponse​(java.io.ByteArrayOutputStream output)
                                      throws org.bidib.jbidibc.messages.exception.ProtocolException
        Description copied from interface: ServerBidibMessageProcessor
        Publish the response in the provided byte array output stream.
        Specified by:
        publishResponse in interface ServerBidibMessageProcessor
        Parameters:
        output - the output stream that contains the responses
        Throws:
        org.bidib.jbidibc.messages.exception.ProtocolException - when can't provide sequence
      • processMessages

        public void processMessages​(java.io.ByteArrayOutputStream output)
                             throws org.bidib.jbidibc.messages.exception.ProtocolException
        Specified by:
        processMessages in interface org.bidib.jbidibc.messages.MessageProcessor
        Throws:
        org.bidib.jbidibc.messages.exception.ProtocolException
      • getErrorInformation

        public java.lang.String getErrorInformation()
        Specified by:
        getErrorInformation in interface org.bidib.jbidibc.core.BidibMessageProcessor
      • addMessageListener

        public void addMessageListener​(org.bidib.jbidibc.core.MessageListener messageListener)
        Specified by:
        addMessageListener in interface org.bidib.jbidibc.core.BidibMessageProcessor
      • removeMessageListener

        public void removeMessageListener​(org.bidib.jbidibc.core.MessageListener messageListener)
        Specified by:
        removeMessageListener in interface org.bidib.jbidibc.core.BidibMessageProcessor
      • addNodeListener

        public void addNodeListener​(org.bidib.jbidibc.core.NodeListener nodeListener)
        Specified by:
        addNodeListener in interface org.bidib.jbidibc.core.BidibMessageProcessor
      • cleanup

        public void cleanup()
        Specified by:
        cleanup in interface org.bidib.jbidibc.messages.MessageReceiver