public void SetHeader(SipHeaderBase header) { Check.Require(header, "header"); switch (header.Name) { case SipHeaderNames.CSeq: _sceq = (SipCSeqHeader)header; break; case SipHeaderNames.CallId: _callId = (SipCallIdHeader)header; break; case SipHeaderNames.Contact: _contacts.Add((SipContactHeader)header); break; case SipHeaderNames.ContentLength: _contentLenght = (SipContentLengthHeader)header; break; case SipHeaderNames.ContentType: _contentType = (SipContentTypeHeader)header; break; case SipHeaderNames.From: _from = (SipFromHeader)header; break; case SipHeaderNames.MaxForwards: _maxForwards = (SipMaxForwardsHeader)header; break; case SipHeaderNames.To: _to = (SipToHeader)header; break; case SipHeaderNames.Via: _vias.Add((SipViaHeader)header); break; case SipHeaderNames.Subject: _subject = (SipSubjectHeader)header; break; case SipHeaderNames.Route: _routes.Add((SipRouteHeader)header); break; case SipHeaderNames.Expires: _expires = (SipExpiresHeader)header; break; case SipHeaderNames.RecordRoute: _recordRoutes.Add((SipRecordRouteHeader)header); break; case SipHeaderNames.Allow: _allow = (SipAllowHeader)header; break; case SipHeaderNames.UserAgent: _userAgent = (SipUserAgentHeader)header; break; default: throw new NotSupportedException(string.Format("The header with name {0} is not supported.", header.Name)); } }
public void RemoveHeader(string header) { Check.Require(header, "header"); switch (header) { case SipHeaderNames.CSeq: _sceq = null; break; case SipHeaderNames.CallId: _callId = null; break; case SipHeaderNames.Contact: _contacts.Clear(); break; case SipHeaderNames.ContentLength: _contentLenght = null; break; case SipHeaderNames.ContentType: _contentType = null; break; case SipHeaderNames.From: _from = null; break; case SipHeaderNames.MaxForwards: _maxForwards = null; break; case SipHeaderNames.To: _to = null; break; case SipHeaderNames.Via: _vias.Clear(); break; case SipHeaderNames.Subject: _subject = null;; break; case SipHeaderNames.Route: _routes.Clear(); break; case SipHeaderNames.Expires: _expires = null; break; case SipHeaderNames.RecordRoute: _recordRoutes.Clear(); break; case SipHeaderNames.Allow: _allow = null; break; case SipHeaderNames.UserAgent: _userAgent = null; break; default: throw new NotSupportedException(string.Format("The header with name {0} is not supported.", header)); } }
public SipRequest CreateRequest(SipUri requestUri, string method, SipCallIdHeader callId, SipCSeqHeader cSeq, SipFromHeader from, SipToHeader to, SipViaHeader viaHeader, SipMaxForwardsHeader maxForwards) { Check.Require(requestUri, "requestUri"); Check.Require(method, "method"); Check.Require(callId, "callId"); Check.Require(cSeq, "cseq"); Check.Require(from, "from"); Check.Require(to, "to"); Check.Require(viaHeader, "viaHeader"); Check.Require(maxForwards, "maxforwards"); var message = new SipRequest(); message.RequestLine.Method = method; message.RequestLine.Uri = requestUri; message.RequestLine.Version = SipConstants.SipTwoZeroString; message.CallId = callId; message.To = to; message.From = from; message.CSeq = cSeq; message.Vias.SetTopMost(viaHeader); message.MaxForwards = maxForwards; return(message); }