/*
 * Copyright (c) 2002-2010 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.util.net.connection;

import com.jscape.util.net.TransportAddress;
import com.jscape.util.service.Service;

/**
 * @author Alex Usun
 */
public interface AsyncConnector<C extends Connection>
        extends Service<AsyncConnector.Listener<C>> {

    TransportAddress boundAddress();

    interface Listener<C extends Connection> {

        void onConnection(AsyncConnector<C> connector, C connection);

        void onError(AsyncConnector<C> connector, Throwable error);

    }

    class NullListener<C extends Connection>
            implements Listener<C> {

        public void onConnection(AsyncConnector<C> connector, C connection) {
            // empty

        }

        public void onError(AsyncConnector<C> connector, Throwable error) {
            // empty
        }
    }
}
