[commit] r8297 - in freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket: . ChannelEvents Commands
Author: verifier Date: Thu May 8 08:00:55 2008 New Revision: 8297 Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/DeflectCmd.cs Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj Log: fixed hangup cause parsing. Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs ============================================================================== --- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs (original) +++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs Thu May 8 08:00:55 2008 @@ -1,77 +1,16 @@ using System; -using System.Collections.Generic; -using System.Text; namespace FreeSwitch.EventSocket { public class EventChannelHangup : EventChannelState { - private Causes m_hangupCause; + private HangupCause _hangupCause; - public enum Causes - { - Success, - NoRouteTransitNet, - NoRouteDestination, - ChannelUnacceptable, - CallAwardedDelivered, - NormalClearing, - UserBusy, - NoUserResponse, - NoAnswer, - SubscriberAbsent, - CallRejected, - NumberChanged, - RedirectionToNewDestination, - ExchangeRoutingError, - DestinationOutOfOrder, - InvalidNumberFormat, - FacilityRejected, - ResponseToStatusEnquiry, - NormalUnspecified, - NormalCircuitCongestion, - NetworkOutOfOrder, - NormalTemporaryFailure, - SwitchCongestion, - AccessInfoDiscarded, - RequestedChanUnavail, - PreEmpted, - FacilityNotSubscribed, - OutgoingCallBarred, - IncomingCallBarred, - BearercapabilityNotauth, - BearercapabilityNotavail, - ServiceUnavailable, - ChanNotImplemented, - FacilityNotImplemented, - ServiceNotImplemented, - InvalidCallReference, - IncompatibleDestination, - InvalidMsgUnspecified, - MandatoryIeMissing, - MessageTypeNonexist, - WrongMessage, - IeNonexist, - InvalidIeContents, - WrongCallState, - RecoveryOnTimerExpire, - MandatoryIeLengthError, - ProtocolError, - Interworking, - OriginatorCancel, - Crash, - SystemShutdown, - LoseRace, - ManagerRequest, - BlindTransfer, - AttendedTransfer, - AllottedTimeout - } - public Causes Cause + public HangupCause Cause { - get { return m_hangupCause; } - set { m_hangupCause = value; } + get { return _hangupCause; } + set { _hangupCause = value; } } public override bool ParseCommand(string name, string value) @@ -79,7 +18,14 @@ if (name == "hangupcause" || name == "hangup-cause") { string cause = StringHelper.UpperCaseToCamelCase(value); - m_hangupCause = (Causes)Enum.Parse(typeof(Causes), cause); + try + { + _hangupCause = (HangupCause)Enum.Parse(typeof(HangupCause), cause, true); + } + catch(ArgumentException) + { + _hangupCause = HangupCause.Unknown; + } } else return base.ParseCommand(name, value); @@ -88,4 +34,67 @@ } } + + public enum HangupCause + { + Success, + NoRouteTransitNet, + NoRouteDestination, + ChannelUnacceptable, + CallAwardedDelivered, + NormalClearing, + UserBusy, + NoUserResponse, + NoAnswer, + SubscriberAbsent, + CallRejected, + NumberChanged, + RedirectionToNewDestination, + ExchangeRoutingError, + DestinationOutOfOrder, + InvalidNumberFormat, + FacilityRejected, + ResponseToStatusEnquiry, + NormalUnspecified, + NormalCircuitCongestion, + NetworkOutOfOrder, + NormalTemporaryFailure, + SwitchCongestion, + AccessInfoDiscarded, + RequestedChanUnavail, + PreEmpted, + FacilityNotSubscribed, + OutgoingCallBarred, + IncomingCallBarred, + BearercapabilityNotauth, + BearercapabilityNotavail, + ServiceUnavailable, + ChanNotImplemented, + FacilityNotImplemented, + ServiceNotImplemented, + InvalidCallReference, + IncompatibleDestination, + InvalidMsgUnspecified, + MandatoryIeMissing, + MessageTypeNonexist, + WrongMessage, + IeNonexist, + InvalidIeContents, + WrongCallState, + RecoveryOnTimerExpire, + MandatoryIeLengthError, + ProtocolError, + Interworking, + OriginatorCancel, + Crash, + SystemShutdown, + LoseRace, + ManagerRequest, + BlindTransfer, + AttendedTransfer, + AllottedTimeout, + UnAllocated, + Unknown + } + } Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs ============================================================================== --- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs (original) +++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs Thu May 8 08:00:55 2008 @@ -19,16 +19,16 @@ public class ChannelInfo { - private ChannelState m_state; - private int m_stateNumber; + private ChannelState _state; + private int _stateNumber; private string _profile; - private string m_address; + private string _address; private string _hostName; - private string m_protocol = string.Empty; - private string m_readCodecName; - private int m_readCodecRate; - private string m_writeCodecName; - private int m_writeCodecRate; + private string _protocol = string.Empty; + private string _readCodecName; + private int _readCodecRate; + private string _writeCodecName; + private int _writeCodecRate; /// <summary> /// Coded used to read information from the channel. @@ -36,8 +36,8 @@ /// </summary> public string ReadCodecName { - get { return m_readCodecName; } - set { m_readCodecName = value; } + get { return _readCodecName; } + set { _readCodecName = value; } } /// <summary> @@ -46,8 +46,8 @@ /// </summary> public int ReadCodecRate { - get { return m_readCodecRate; } - set { m_readCodecRate = value; } + get { return _readCodecRate; } + set { _readCodecRate = value; } } /// <summary> @@ -56,8 +56,8 @@ /// </summary> public string WriteCodecName { - get { return m_writeCodecName; } - set { m_writeCodecName = value; } + get { return _writeCodecName; } + set { _writeCodecName = value; } } /// <summary> @@ -66,8 +66,8 @@ /// </summary> public int WriteCodecRate { - get { return m_writeCodecRate; } - set { m_writeCodecRate = value; } + get { return _writeCodecRate; } + set { _writeCodecRate = value; } } /// <summary> @@ -75,8 +75,8 @@ /// </summary> public ChannelState State { - get { return m_state; } - set { m_state = value; } + get { return _state; } + set { _state = value; } } /// <summary> @@ -84,8 +84,8 @@ /// </summary> public int StateNumber { - get { return m_stateNumber; } - set { m_stateNumber = value; } + get { return _stateNumber; } + set { _stateNumber = value; } } /// <summary> @@ -98,22 +98,22 @@ /// <seealso cref="HostName"/> public string Name { - get { return m_protocol + "/" + _profile + "/" + m_address + "@" + _hostName; } + get { return _protocol + "/" + _profile + "/" + _address + "@" + _hostName; } set { string[] bits = value.Split('/'); if (bits.Length == 3) { - m_protocol = bits[0]; + _protocol = bits[0]; _profile = bits[1]; string[] userParts = bits[2].Split('@'); if (userParts.Length == 2) { - m_address = userParts[0]; + _address = userParts[0]; HostName = userParts[1]; } else - m_address = bits[2]; + _address = bits[2]; } } @@ -133,8 +133,8 @@ /// </summary> public string Address { - get { return m_address; } - set { m_address = value; } + get { return _address; } + set { _address = value; } } /// <summary> @@ -165,7 +165,7 @@ /// </summary> public string Protocol { - get { return m_protocol; } + get { return _protocol; } } public bool Parse(string name, string value) @@ -173,25 +173,25 @@ switch (name) { case "channel-state": - m_state = StateFromString(value); + _state = StateFromString(value); break; case "channel-state-number": - int.TryParse(value, out m_stateNumber); + int.TryParse(value, out _stateNumber); break; case "channel-name": Name = value; break; case "channel-read-codec-name": - m_readCodecName = value; + _readCodecName = value; break; case "channel-read-codec-rate": - int.TryParse(value, out m_readCodecRate); + int.TryParse(value, out _readCodecRate); break; case "channel-write-codec-name": - m_writeCodecName = value; + _writeCodecName = value; break; case "channel-write-codec-rate": - int.TryParse(value, out m_writeCodecRate); + int.TryParse(value, out _writeCodecRate); break; default: return false; Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/DeflectCmd.cs ============================================================================== --- (empty file) +++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/DeflectCmd.cs Thu May 8 08:00:55 2008 @@ -0,0 +1,37 @@ +using System; + +namespace FreeSwitch.EventSocket.Commands +{ + public class DeflectCmd : SendMsg + { + private readonly string _uri; + + /// <summary> + /// + /// </summary> + /// <param name="uuid">session id</param> + /// <param name="sipUri">complete sip uri, with or whithout "sip:"</param> + public DeflectCmd(string uuid, string sipUri) + : base(uuid, "execute") + { + if (string.IsNullOrEmpty(sipUri)) + throw new ArgumentNullException("sipUri"); + + _uri = sipUri; + } + + public DeflectCmd(string uuid) : base(uuid) + { + } + + public override string Command + { + get { return "deflect"; } + } + + public override string Arguments + { + get { return _uri; } + } + } +} Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs ============================================================================== --- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs (original) +++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs Thu May 8 08:00:55 2008 @@ -1,3 +1,5 @@ +using System; + namespace FreeSwitch.EventSocket.Commands { public abstract class SendMsg : CmdBase @@ -7,11 +9,18 @@ public SendMsg(string uuid) { + if (string.IsNullOrEmpty(uuid)) + throw new ArgumentNullException("uuid"); _uuid = uuid; } public SendMsg(string uuid, string callCommand) { + if (string.IsNullOrEmpty(uuid)) + throw new ArgumentNullException("uuid"); + if (string.IsNullOrEmpty(callCommand)) + throw new ArgumentNullException("callCommand"); + _callCommand = callCommand; _uuid = uuid; } Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj ============================================================================== --- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj (original) +++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj Thu May 8 08:00:55 2008 @@ -54,6 +54,7 @@ <Compile Include="Commands\AuthCommand.cs" /> <Compile Include="Commands\CmdBase.cs" /> <Compile Include="Commands\CommandReply.cs" /> + <Compile Include="Commands\DeflectCmd.cs" /> <Compile Include="Commands\ExecuteJavascript.cs" /> <Compile Include="Commands\GetVariable.cs" /> <Compile Include="Commands\HoldCmd.cs" />
participants (1)
-
Freeswitch SVN