Пример #1
0
        /// <summary>
        /// This method is fired when call is disconnected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void phone_ConnectionCleared(object sender, ConnectionClearedEventArgs args)
        {
            DateTime callReleaseTime = DateTime.Now;
            Connection droppedConn = args.DroppedConnection;

            /**
             * If connection cleared was received in response to active or pending connection, take appropriate action
             * or else do nothing.
             */
            if (conn != null && conn.Equals(droppedConn) == true)
            {
                missingHangupDetectionTimer.Enabled = false;
                conn = args.DroppedConnection;

                if (missingHangupDetected == false)
                {
                    display("Received connection cleared for Iteration " + currIter);
                    processHangup(callReleaseTime);
                }
                else
                {
                    display("Received connection cleared in response to callee clearing call on not detecting a hangup");
                    processHangup(new DateTime());
                    missingHangupDetected = false; // This is set to false to prepare callee for next call iteration
                }
                setState(CurrentState.READY);

                /**
                 * If callee does not detect hangup and releases the ongoing call, we need to ensure that if an actual hangup is received
                 * after this call is released, it should not be processed. Thus, we set conn to null so that it will not pass through the
                 * previous if block and not get processed.
                 */
                conn = null;
            }
            else
            {
                display("Ignored connection cleared event because it was not in a response to an established call. Connection object details = " + droppedConn.ToString());
            }
        }
Пример #2
0
        /// <summary>
        /// This method is fired when call is hungup.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void phone_ConnectionCleared(object sender, ConnectionClearedEventArgs args)
        {
            DateTime callReleaseTimeStamp = DateTime.Now;
            Connection droppedConn = args.DroppedConnection;

            /**
             * If connection cleared was received in response to active or dialing connection, take appropriate action
             * or else do nothing.
             */
            if (conn != null && conn.Equals(droppedConn) == true)
            {
                conn = args.DroppedConnection;

                // Store the timestamp when call was disconnected with callerData
                callerData.callReleaseTime = callReleaseTimeStamp;

                // Disable all timers to prevent them from accidentally firing in next iteration
                callDurationTimer.Enabled = false;
                bargeTimer.Enabled = false;

                try
                {
                    if (ll != null)
                        ll.Stop();
                    if (recorder != null)
                        recorder.Stop();
                }
                catch (Exception e)
                {
                    Trace.TraceError("Exception in phone_ConnectionCleared. Message: " + e.Message + "Current time = " + DateTime.Now + "\r\nStack Trace : \r\n" + e.StackTrace, "Warning");
                }

                // After processing a connection cleared, send the notification of call state for the caller to the observer.
                // Make sure to set the callerData to null - this is a safety mechanism to prevent same iteration being logged
                // multiple times (if multiple connection cleared) are received in response to makecall
                if (OnIterationCompleted != null && callerData != null)
                {
                    OnIterationCompleted(this, callerData);
                    callerData = null;
                }

                int temp;

                lock (this)
                {
                    temp = numRemainingIter;
                }
                if (temp > 0)
                {
                    setState(CurrentState.READY);
                    display("Enabling inter-call wait timer");
                    // Start the timer to place the next call
                    interCallTimer.Enabled = true;
                }
                else
                {
                    setState(CurrentState.EXECUTION_COMPLETED);
                }
            }
            else
            {
                /**
                 * If connection cleared was ignored, print out the time that happened, and also the reason.
                 * If conn was null say that. If conn was not equivalent to dropped connection, say that, otherwise
                 * set the reason as "Unknown".
                 */
                StringBuilder message = new StringBuilder();
                message.Append("Ignoring connection cleared event at time = " + DateTime.Now + " Reason: ");

                if (conn == null)
                {
                    message.Append("Preserved connection was null");
                }
                else
                {
                    message.Append("Preserved connection is not equivalent to dropped connection");
                }

                display(message.ToString());
            }
        }