/*
 * @(#)BsdListener.java
 *
 * Copyright (c) 2001-2002 JScape
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JScape. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JScape.
 */
package com.jscape.inet.bsd;

import 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. <br>
 * 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:<br>
 * <pre>
 * 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);
 * }
 * </pre>
 */
public interface BsdListener
        extends EventListener {
    /**
     * Invoked when connection to BSD r service server is established.
     *
     * @param event a <code>BsdConnectedEvent</code>
     *
     * @see BsdConnectedEvent
     */
    void connected(BsdConnectedEvent event);

    /**
     * Invoked when connection to BSD r service server is released.
     *
     * @param event a <code>BsdDisconnectedEvent</code>
     *
     * @see BsdDisconnectedEvent
     */
    void disconnected(BsdDisconnectedEvent event);

    /**
     * Invoked when data is transmitted to an OutputStream.
     *
     * @param event a <code>BsdBytesTransmittedEvent</code>
     */
    void bytesTransmitted(BsdBytesTransmittedEvent event);

    /**
     * Invoked when data arrives from an InputStream.
     *
     * @param event a <code>BsdBytesReceivedEvent</code>
     */
    void bytesReceived(BsdBytesReceivedEvent event);
}
