GetStatusTypeForCode() public static method

public static GetStatusTypeForCode ( int statusCode ) : SIPResponseStatusCodesEnum
statusCode int
return SIPResponseStatusCodesEnum
Example #1
0
        public static SIPResponse ParseSIPResponse(SIPMessage sipMessage)
        {
            try
            {
                SIPResponse sipResponse = new SIPResponse();
                sipResponse.LocalSIPEndPoint  = sipMessage.LocalSIPEndPoint;
                sipResponse.RemoteSIPEndPoint = sipMessage.RemoteSIPEndPoint;
                string statusLine = sipMessage.FirstLine;

                int firstSpacePosn = statusLine.IndexOf(" ");

                sipResponse.SIPVersion   = statusLine.Substring(0, firstSpacePosn).Trim();
                statusLine               = statusLine.Substring(firstSpacePosn).Trim();
                sipResponse.StatusCode   = Convert.ToInt32(statusLine.Substring(0, 3));
                sipResponse.Status       = SIPResponseStatusCodes.GetStatusTypeForCode(sipResponse.StatusCode);
                sipResponse.ReasonPhrase = statusLine.Substring(3).Trim();

                sipResponse.Header = SIPHeader.ParseSIPHeaders(sipMessage.SIPHeaders);
                sipResponse.Body   = sipMessage.Body;

                return(sipResponse);
            }
            catch (SIPValidationException)
            {
                throw;
            }
            catch (Exception excp)
            {
                logger.LogError("Exception ParseSIPResponse. " + excp.Message);
                logger.LogError(sipMessage.RawMessage);
                throw new SIPValidationException(SIPValidationFieldsEnum.Response, "Error parsing SIP Response");
            }
        }