public static void HandleHangupCompleteEvent(FSEvent evt, String uuid)
{
Utils.DebugEventDump(evt);
Call call = (from c in calls where c.call_ended == false && (c.leg_a_uuid == uuid || c.leg_b_uuid == uuid) select c).SingleOrDefault();
if (call == null || call.call_ended)
return;
CALL_STATE new_state = CALL_STATE.None;
if (call.state != CALL_STATE.Answered && call.state != CALL_STATE.Missed && call.state != CALL_STATE.Hold) {
if (String.IsNullOrEmpty(call.note))
call.note = evt.get_header("variable_sip_hangup_phrase");
if (!call.is_outgoing && call.state == CALL_STATE.Ringing)
new_state = CALL_STATE.Missed;
else
new_state = CALL_STATE.Failed;
}
else if (call.state == CALL_STATE.Answered || call.state == CALL_STATE.Hold)
new_state = CALL_STATE.Ended;
if (new_state == CALL_STATE.None)
throw new Exception("Not sure what happened call was at state...: " + call.state);
Call new_active_call;
if (Call.active_call != call)
new_active_call = Call.active_call;
else
new_active_call = (from c in calls where c.state == CALL_STATE.Ringing && c.is_outgoing == false && c != call select c).FirstOrDefault();
call.UpdateCallState(new_state, new_active_call);
}