com.jscape.inet.bsd

## Interface BsdListener

- All Superinterfaces:
    java.util.EventListener
  All Known Implementing Classes:
    BsdAdapter

      public interface BsdListener
      extends java.util.EventListener

  Implements methods for capturing connected and disconnected events from Rexec and derived classes. Class that implements this interface can also capture data flow events sourced from InputWriter and OutputReader classes of bsd package. Your application should implement this interface to capture the events of data flow between remote host and local machine.
  Typical use of the listener would be to monitor the traffic in data streams. Simple implementation, which only counts the bytes transferred may look somewhat like this:

       Rlogin rlogin = new Rlogin("remote.host.com", "johndoe", "johndoe", "vt100");
       try
       {
         rlogin.connect();
         rlogin.execute();
         class OutputReaderListenerClass implements BsdListener
         {
           long total=0;
           public void connected(BsdConnectedEvent event) {}
           public void disconnected(BsdDisconnectedEvent event) {}
           public void bytesTransmitted(BsdBytesTransmittedEvent event) {}
           public void bytesReceived(BsdBytesReceivedEvent event)
           {
             this.total = event.getTotal();
           }
         }
         class InputWriterListenerClass implements BsdListener
         {
           long total=0;
           public void connected(BsdConnectedEvent event) {}
           public void disconnected(BsdDisconnectedEvent event) {}
           public void bytesReceived(BsdBytesReceivedEvent event) {}
           public void bytesTransmitted(BsdBytesTransmittedEvent event)
           {
             this.total = event.getTotal();
           }
         }
         OutputReaderListenerClass OutputReaderListener = new OutputReaderListenerClass();
         InputWriterListenerClass InputWriterListener = new InputWriterListenerClass();
         OutputReader reader = new OutputReader(rlogin.getInputStream(), System.out, rlogin.getBsdListeners());
         InputWriter writer = new InputWriter(System.in, rlogin.getOutputStream(), rlogin.getBsdListeners());
         rlogin.addBsdListener(OutputReaderListener);
         rlogin.addBsdListener(InputWriterListener);
         reader.setPriority(Thread.currentThread().getPriority() + 1);
         reader.start();
         writer.setDaemon(true);
         writer.start();
         try
         {
           reader.join();
           writer.interrupt();
         }
         catch(InterruptedException e) {}
         System.out.println("Bytes received: " + OutputReaderListener.total);
         System.out.println("Bytes sent: " + InputWriterListener.total);
       }
       catch(Exception e)
       {
         System.out.println(e);
       }

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bytesReceived(BsdBytesReceivedEvent event)` Invoked when data arrives from an InputStream.
    `void` | `bytesTransmitted(BsdBytesTransmittedEvent event)` Invoked when data is transmitted to an OutputStream.
    `void` | `connected(BsdConnectedEvent event)` Invoked when connection to BSD r service server is established.
    `void` | `disconnected(BsdDisconnectedEvent event)` Invoked when connection to BSD r service server is released.

- - ### Method Detail

    - #### connected

          void connected(BsdConnectedEvent event)

      Invoked when connection to BSD r service server is established.
      Parameters:
        `event` - a `BsdConnectedEvent`
      See Also:
        `BsdConnectedEvent`

    - #### disconnected

          void disconnected(BsdDisconnectedEvent event)

      Invoked when connection to BSD r service server is released.
      Parameters:
        `event` - a `BsdDisconnectedEvent`
      See Also:
        `BsdDisconnectedEvent`

    - #### bytesTransmitted

          void bytesTransmitted(BsdBytesTransmittedEvent event)

      Invoked when data is transmitted to an OutputStream.
      Parameters:
        `event` - a `BsdBytesTransmittedEvent`

    - #### bytesReceived

          void bytesReceived(BsdBytesReceivedEvent event)

      Invoked when data arrives from an InputStream.
      Parameters:
        `event` - a `BsdBytesReceivedEvent`

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved