
/**
 * PushByteSourceImpl.java
 *
 *
 * Created: Fri Jun 27 09:48:40 2003
 *
 * @author <a href="mailto: jan@newmarch.name">jan newmarch</a>
 * @version
 */

package pushbytes;

import common.*;
import transport.*;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;

public class PushByteSourceImpl extends UnicastRemoteObject 
                                implements PushByteSource {
    PushByteSink sink;

    public PushByteSourceImpl () throws RemoteException {
    }

    public void play() {
        if (sink == null) {
            return;
        }

        byte[] bytes = null;
        sink.record(bytes);
    }

    public void stop() {
    }

    public void addSink(Sink sink) throws 
	    TooManySinksException,
	    IncompatableSinkException {
        if (this.sink != null) {
            throw new TooManySinksException();
        }
        if (sink instanceof PushByteSink) {
            this.sink = (PushByteSink) sink;
        } else {
            throw new IncompatableSinkException();
        }
    }

    public void removeSink(Sink sink) throws NoSuchSinkException {
        if (this.sink == sink) {
            this.sink = null;
        } else {
            throw new NoSuchSinkException();
        }
    }

    public net.jini.core.event.EventRegistration addSourceListener(net.jini.core.event.RemoteEventListener listener,
				  java.rmi.MarshalledObject obj) {
	return null;
    }
}// PushByteSourceImpl
