Class TcpServerNetMessageHandler

java.lang.Object
jmri.jmrix.bidib.tcpserver.TcpServerNetMessageHandler
All Implemented Interfaces:
org.bidib.jbidibc.net.serialovertcp.NetMessageHandler

public class TcpServerNetMessageHandler extends Object implements org.bidib.jbidibc.net.serialovertcp.NetMessageHandler
This is the network message handler for both directions. It receives the raw data from the TCP socket and forwards them to the message receiver. The send() message is called from the BiDiBMessageReceiver to send data from tge BiDIB connection back to the TCP client. Data is encoded with the serial encoder (i.e. add the Magic bytes etc.) and then sent to the NetBidibPort, which then finally send the messages to all connected clients.
  • Constructor Details

    • TcpServerNetMessageHandler

      public TcpServerNetMessageHandler(org.bidib.jbidibc.messages.MessageReceiver messageReceiverDelegate)
  • Method Details

    • receive

      public void receive(org.bidib.jbidibc.net.serialovertcp.DataPacket packet)
      Specified by:
      receive in interface org.bidib.jbidibc.net.serialovertcp.NetMessageHandler
    • send

      public void send(org.bidib.jbidibc.net.serialovertcp.NetBidibPort port, byte[] data)
      Send serial encoded data (one or more messages) to the to the TCP port
      Specified by:
      send in interface org.bidib.jbidibc.net.serialovertcp.NetMessageHandler
      Parameters:
      port - the port
      data - the data
    • acceptClient

      public void acceptClient(String remoteHost)
      Specified by:
      acceptClient in interface org.bidib.jbidibc.net.serialovertcp.NetMessageHandler
    • cleanup

      public void cleanup(String remoteHost)
      Specified by:
      cleanup in interface org.bidib.jbidibc.net.serialovertcp.NetMessageHandler