package de.dtele.net.protocol {

  import de.dtele.net.MediaRequest;
  import de.dtele.net.events.ProtocolHandlerEvent;
  
  import flash.events.IEventDispatcher;
  
  /**
   * Dispatched when the handler has connected to a source
   * 
   * @eventType de.dtele.net.events.ProtocolHandlerEvent.CONNECTED
   */
  [Event("connected", type="de.dtele.net.events.ProtocolHandlerEvent")]
  
  /**
   * Dispatched when the handler has disconnected from a source
   * 
   * @eventType de.dtele.net.events.ProtocolHandlerEvent.DISCONNECTED
   */
  [Event("disconnected", type="de.dtele.net.events.ProtocolHandlerEvent")]
  
  /**
   * Dispatched when the handler has received a message from a source
   * 
   * @eventType de.dtele.net.events.ProtocolHandlerResponseEvent.RESPONSE
   */
  [Event("response", type="de.dtele.net.events.ProtocolHandlerEvent")]
  
  /**
   * General interface for all protocol handlers
   * 
   * @author Mathias Brodala
   */
  public interface IProtocolHandler extends IEventDispatcher {
    
    /**
     * Connects the handler to a source
     * 
     * @param url The url of a source
     */
    function connect(url:String):void;
    
    /**
     * Disconnects the handler from a source
     */
    function disconnect():void;
    
    /**
     * Performs a request to a source
     * 
     * @param request The MediaRequest to submit
     */
    function send(request:MediaRequest):void;
  }
}