Package jmri.jmrix.bidib.tcpserver
Class ServerMessageReceiver
- java.lang.Object
-
- jmri.jmrix.bidib.tcpserver.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.
-
-
Constructor Summary
Constructors Constructor Description ServerMessageReceiver(BiDiBTrafficController tc)
-
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)
-
-
-
Constructor Detail
-
ServerMessageReceiver
public ServerMessageReceiver(BiDiBTrafficController tc)
-
-
Method Detail
-
enable
public void enable()
- Specified by:
enable
in interfaceServerBidibMessageProcessor
-
disable
public void disable()
- Specified by:
disable
in interfaceServerBidibMessageProcessor
-
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 interfaceorg.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 interfaceServerBidibMessageProcessor
- 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 interfaceorg.bidib.jbidibc.messages.MessageProcessor
- Throws:
org.bidib.jbidibc.messages.exception.ProtocolException
-
getErrorInformation
public java.lang.String getErrorInformation()
- Specified by:
getErrorInformation
in interfaceorg.bidib.jbidibc.core.BidibMessageProcessor
-
addMessageListener
public void addMessageListener(org.bidib.jbidibc.core.MessageListener messageListener)
- Specified by:
addMessageListener
in interfaceorg.bidib.jbidibc.core.BidibMessageProcessor
-
removeMessageListener
public void removeMessageListener(org.bidib.jbidibc.core.MessageListener messageListener)
- Specified by:
removeMessageListener
in interfaceorg.bidib.jbidibc.core.BidibMessageProcessor
-
addNodeListener
public void addNodeListener(org.bidib.jbidibc.core.NodeListener nodeListener)
- Specified by:
addNodeListener
in interfaceorg.bidib.jbidibc.core.BidibMessageProcessor
-
cleanup
public void cleanup()
- Specified by:
cleanup
in interfaceorg.bidib.jbidibc.messages.MessageReceiver
-
-