package de.dtele.net.protocol {
  
  import flash.events.IEventDispatcher;
  
  /**
   * Definition of the WebSocket interface
   * 
   * @see http://dev.w3.org/html5/websockets/#websocket
   * 
   * @author Mathias Brodala
   */
  public interface IWebSocket extends IEventDispatcher {
    
    /**
     * The result of resolving the URL that was passed to the constructor
     * 
     * @see http://dev.w3.org/html5/websockets/#dom-websocket-url
     * @return The URL
     */
    function get url():String;
    
    /**
     * Represents the state of the connection
     * 
     * @see http://dev.w3.org/html5/websockets/#dom-websocket-readystate
     * @return The state
     */
    function get readyState():uint;
    
    /**
     * The number of bytes of UTF-8 text that have been queued using send()
     * but that, as of the last time the event loop started executing a task,
     * had not yet been transmitted to the network
     * 
     * @see http://dev.w3.org/html5/websockets/#dom-websocket-bufferedamount
     * @return The buffered amount
     */
    function get bufferedAmount():Number;
    
    /**
     * Transmits data using the connection
     * 
     * @see http://dev.w3.org/html5/websockets/#dom-websocket-send
     * @param data The data to transmit
     */
    function send(data:String):void;
    
    /**
     * Closes the connection
     * 
     * @see http://dev.w3.org/html5/websockets/#dom-websocket-close
     */
    function close():void;
  }
}