/*
 Copyright (c) 2006 - 2008  Eric J. Feminella  <eric@ericfeminella.com>
 All rights reserved.

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is furnished
 to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 @internal
 */

package com.ericfeminella.rpc.instrumentation
{
    import flash.events.Event;

    /**
     *
     * <code>RPCDiagnosticsEvent</code> provides an <code>Event</code>
     * which contains information specific to an <code>RPCDiagnostics</code>
     * instance.
     *
     * @see RPCDiagnostics
     *
     */
    public class RPCDiagnosticsEvent extends Event
    {
        /**
         *
         * Defines the <code>Event.type</code> which this event is
         * associated.
         *
         */
        public static const EXECUTION_COMPLETE:String = "executionComplete";

        /**
         *
         * @private
         *
         * Defines the <code>operationName</code> which this invocation
         * is associated with.
         *
         */
        private var _operationName:String;

        /**
         *
         * @private
         *
         * The amount of time the operation took to execute from the
         * client to the server and back to the client.
         *
         */
        private var _duration:int;

        /**
         *
         * <code>RPCDiagnosticsEvent</code> constructor requires the specific
         * <code>operationName</code> and <code>duration</code> resulting from
         * an <code>RPCDiagnostics</code> instance.
         *
         * @param The name of the operation which is being monitored.
         * @param Amount of time the operation took to completed.
         *
         */
        public function RPCDiagnosticsEvent(operationName:String, duration:int)
        {
            super( EXECUTION_COMPLETE, bubbles, cancelable );
            _operationName = operationName;
            _duration   = duration;
        }

        /**
         *
         * Defines the <code>operationName</code> which this invocation
         * is associated with.
         *
         * @return The name of the operation which is being monitored
         *
         */
        public function get operationName() : String
        {
            return _operationName;
        }

        /**
         *
         * The amount of time the operation took to execute from the
         * client to the server and back to the client.
         *
         * @return Amount of time the operation took to completed.
         *
         */
        public function get duration() : int
        {
            return _duration;
        }
    }
}