1  /**
     2   * com.sekati.log.LCBinding
     3   * @version 1.1.1
     4   * @author jason m horwitz | sekati.com
     5   * Copyright (C) 2007  jason m horwitz, Sekat LLC. All Rights Reserved.
     6   * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
     7   */
     8  
     9  import com.sekati.events.Event;
    10  
    11  /**
    12   * Centralize {@link Console} & {@link Logger} LocalConnections.
    13   */
    14  class com.sekati.log.LCBinding {
    15  
    16  	private static var _rx:LocalConnection = new LocalConnection( );
    17  	private static var _tx:LocalConnection = new LocalConnection( );	
    18  	public static var connectionName:String = "_com.sekati.log.LCBinding";
    19  	public static var methodName:String = "lcHandler";
    20  
    21  	/**
    22  	 * Set reciever handler, allow sends from any dom and connect.
    23  	 * @param handler (Function) Delegate to method call
    24  	 * @return Void
    25  	 */
    26  	public static function connect(handler:Function):Void {
    27  		LCBinding._rx.allowDomain = _rx.allowInsecureDomain = LCBinding.domain;
    28  		LCBinding._rx[LCBinding.methodName] = handler;
    29  		LCBinding._rx.connect( LCBinding.connectionName );
    30  	}
    31  
    32  	/**
    33  	 * Disconnect reciever.
    34  	 * @return Void
    35  	 */
    36  	public static function disconnect():Void {
    37  		LCBinding._rx.close( );
    38  	}
    39  
    40  	/**
    41  	 * Send a call to localConnection.
    42  	 * @param eventObj (Event) item event data
    43  	 * @return Void
    44  	 */
    45  	public static function send(eventObj:Event):Void {
    46  		LCBinding._tx.allowDomain = LCBinding._tx.allowInsecureDomain = LCBinding.domain;
    47  		LCBinding._tx.send( LCBinding.connectionName, LCBinding.methodName, eventObj.data );
    48  	}	
    49  
    50  	/**
    51  	 * Open LocalConnection to all domains.
    52  	 * @return Boolean
    53  	 */
    54  	public static function domain():Boolean {
    55  		return true;
    56  	}
    57  
    58  	private function LCBinding() {	
    59  	}
    60  }