本文整理汇总了Java中gov.nist.javax.sip.header.CSeq类的典型用法代码示例。如果您正苦于以下问题:Java CSeq类的具体用法?Java CSeq怎么用?Java CSeq使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CSeq类属于gov.nist.javax.sip.header包,在下文中一共展示了CSeq类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkHeaders
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Check the response structure. Must have from, to CSEQ and VIA
* headers.
*/
public void checkHeaders() throws ParseException {
if (getCSeq() == null) {
throw new ParseException(CSeq.NAME+ " Is missing ", 0);
}
if (getTo() == null) {
throw new ParseException(To.NAME+ " Is missing ", 0);
}
if (getFrom() == null) {
throw new ParseException(From.NAME+ " Is missing ", 0);
}
if (getViaHeaders() == null) {
throw new ParseException(Via.NAME+ " Is missing ", 0);
}
if (getCallId() == null) {
throw new ParseException(CallID.NAME + " Is missing ", 0);
}
if (getStatusCode() > 699) {
throw new ParseException("Unknown error code!" + getStatusCode(), 0);
}
}
示例2: handleException
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Implementation of the ParseExceptionListener interface.
*
* @param ex
* Exception that is given to us by the parser.
* @throws ParseException
* If we choose to reject the header or message.
*/
public void handleException(ParseException ex, SIPMessage sipMessage,
Class hdrClass, String header, String message)
throws ParseException {
if (logger.isLoggingEnabled())
this.logger.logException(ex);
// Log the bad message for later reference.
if ((hdrClass != null)
&& (hdrClass.equals(From.class) || hdrClass.equals(To.class)
|| hdrClass.equals(CSeq.class)
|| hdrClass.equals(Via.class)
|| hdrClass.equals(CallID.class)
|| hdrClass.equals(ContentLength.class)
|| hdrClass.equals(RequestLine.class) || hdrClass
.equals(StatusLine.class))) {
if (logger.isLoggingEnabled()) {
logger.logError("BAD MESSAGE!");
logger.logError(message);
}
throw ex;
} else {
sipMessage.addUnparsed(header);
}
}
示例3: handleException
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Implementation of the ParseExceptionListener interface.
*
* @param ex
* Exception that is given to us by the parser.
* @throws ParseException
* If we choose to reject the header or message.
*
* JvB: copied from UDPMessageChannel, TODO restructure!
*/
public void handleException(ParseException ex, SIPMessage sipMessage,
Class hdrClass, String header, String message)
throws ParseException {
if (getSIPStack().isLoggingEnabled())
this.logger.logException(ex);
// Log the bad message for later reference.
if ((hdrClass != null)
&& (hdrClass.equals(From.class) || hdrClass.equals(To.class)
|| hdrClass.equals(CSeq.class)
|| hdrClass.equals(Via.class)
|| hdrClass.equals(CallID.class)
|| hdrClass.equals(RequestLine.class) || hdrClass
.equals(StatusLine.class))) {
logger.logError("BAD MESSAGE!");
logger.logError(message);
throw ex;
} else {
sipMessage.addUnparsed(header);
}
}
示例4: setRequestLineDefaults
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Patch up the request line as necessary.
*/
protected void setRequestLineDefaults() {
String method = requestLine.getMethod();
if (method == null) {
CSeq cseq = (CSeq) this.getCSeq();
if (cseq != null) {
method = getCannonicalName(cseq.getMethod());
requestLine.setMethod(method);
}
}
}
示例5: removeHeader
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Remove all headers given its name.
*
* @param headerName is the name of the header to remove.
*/
public void removeHeader(String headerName) {
if (headerName == null)
throw new NullPointerException("null arg");
String headerNameLowerCase = SIPHeaderNamesCache.toLowerCase(headerName);
SIPHeader removed = (SIPHeader) headerTable.remove(headerNameLowerCase);
// nothing to do then we are done.
if (removed == null)
return;
// Remove the fast accessor fields.
if (removed instanceof From) {
this.fromHeader = null;
} else if (removed instanceof To) {
this.toHeader = null;
} else if (removed instanceof CSeq) {
this.cSeqHeader = null;
} else if (removed instanceof CallID) {
this.callIdHeader = null;
} else if (removed instanceof MaxForwards) {
this.maxForwardsHeader = null;
} else if (removed instanceof ContentLength) {
this.contentLengthHeader = null;
}
Iterator<SIPHeader> li = this.headers.iterator();
while (li.hasNext()) {
SIPHeader sipHeader = (SIPHeader) li.next();
if (sipHeader.getName().equalsIgnoreCase(headerNameLowerCase))
li.remove();
}
}
示例6: createRequest
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Generate a request from a response.
*
* @param requestURI
* -- the request URI to assign to the request.
* @param via
* -- the Via header to assign to the request
* @param cseq
* -- the CSeq header to assign to the request
* @param from
* -- the From header to assign to the request
* @param to
* -- the To header to assign to the request
* @return -- the newly generated sip request.
*/
public SIPRequest createRequest(SipUri requestURI, Via via, CSeq cseq,
From from, To to) {
SIPRequest newRequest = new SIPRequest();
String method = cseq.getMethod();
newRequest.setMethod(method);
newRequest.setRequestURI(requestURI);
this.setBranch(via, method);
newRequest.setHeader(via);
newRequest.setHeader(cseq);
newRequest.setHeader(from);
newRequest.setHeader(to);
newRequest.setHeader(getCallId());
try {
// JvB: all requests need a Max-Forwards
newRequest.attachHeader(new MaxForwards(70), false);
} catch (Exception d) {
}
if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
newRequest
.setHeader(MessageFactoryImpl.getDefaultUserAgentHeader());
}
return newRequest;
}
示例7: handleException
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Exception processor for exceptions detected from the parser. (This is
* invoked by the parser when an error is detected).
*
* @param sipMessage
* -- the message that incurred the error.
* @param ex
* -- parse exception detected by the parser.
* @param header
* -- header that caused the error.
* @throws ParseException
* Thrown if we want to reject the message.
*/
public void handleException(ParseException ex, SIPMessage sipMessage,
Class hdrClass, String header, String message)
throws ParseException {
if (logger.isLoggingEnabled())
logger.logException(ex);
// Log the bad message for later reference.
if ((hdrClass != null)
&& (hdrClass.equals(From.class) || hdrClass.equals(To.class)
|| hdrClass.equals(CSeq.class)
|| hdrClass.equals(Via.class)
|| hdrClass.equals(CallID.class)
|| hdrClass.equals(ContentLength.class)
|| hdrClass.equals(RequestLine.class) || hdrClass
.equals(StatusLine.class))) {
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("Encountered Bad Message \n"
+ sipMessage.toString());
}
// JvB: send a 400 response for requests (except ACK)
// Currently only UDP, @todo also other transports
String msgString = sipMessage.toString();
if (!msgString.startsWith("SIP/") && !msgString.startsWith("ACK ")) {
if (socketChannel != null) {
if (logger.isLoggingEnabled(LogWriter.TRACE_ERROR)) {
logger
.logError("Malformed mandatory headers: closing socket! :"
+ socketChannel.toString());
}
try {
socketChannel.close();
} catch (IOException ie) {
if (logger.isLoggingEnabled(LogWriter.TRACE_ERROR)) {
logger.logError("Exception while closing socket! :"
+ socketChannel.toString() + ":" + ie.toString());
}
}
}
}
throw ex;
} else {
sipMessage.addUnparsed(header);
}
}
示例8: handleException
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
/**
* Exception processor for exceptions detected from the parser. (This is
* invoked by the parser when an error is detected).
*
* @param sipMessage
* -- the message that incurred the error.
* @param ex
* -- parse exception detected by the parser.
* @param header
* -- header that caused the error.
* @throws ParseException
* Thrown if we want to reject the message.
*/
public void handleException(ParseException ex, SIPMessage sipMessage,
Class hdrClass, String header, String message)
throws ParseException {
if (logger.isLoggingEnabled())
logger.logException(ex);
// Log the bad message for later reference.
if ((hdrClass != null)
&& (hdrClass.equals(From.class) || hdrClass.equals(To.class)
|| hdrClass.equals(CSeq.class)
|| hdrClass.equals(Via.class)
|| hdrClass.equals(CallID.class)
|| hdrClass.equals(ContentLength.class)
|| hdrClass.equals(RequestLine.class) || hdrClass
.equals(StatusLine.class))) {
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug(
"Encountered Bad Message \n" + sipMessage.toString());
}
// JvB: send a 400 response for requests (except ACK)
// Currently only UDP, @todo also other transports
String msgString = sipMessage.toString();
if (!msgString.startsWith("SIP/") && !msgString.startsWith("ACK ")) {
if(mySock != null)
{
if (logger.isLoggingEnabled(LogWriter.TRACE_ERROR)) {
logger.logError("Malformed mandatory headers: closing socket! :" + mySock.toString());
}
try
{
mySock.close();
} catch(IOException ie)
{
if (logger.isLoggingEnabled(LogWriter.TRACE_ERROR)) {
logger.logError("Exception while closing socket! :" + mySock.toString() + ":" + ie.toString());
}
}
}
}
throw ex;
} else {
sipMessage.addUnparsed(header);
}
}
示例9: main
import gov.nist.javax.sip.header.CSeq; //导入依赖的package包/类
public static void main( String[] args ) throws Exception {
SipFactory sipFactory = null;
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
MessageFactory messageFactory = sipFactory.createMessageFactory();
Message message = messageFactory.createRequest(message1);
// Create an empty request.
Message matchTemplate = messageFactory.createRequest(null);
HeaderFactory headerFactory = sipFactory.createHeaderFactory();
CSeqHeader cseqHeader =
headerFactory.createCSeqHeader(1L,Request.INVITE);
gov.nist.javax.sip.header.CSeq cseq = (CSeq)cseqHeader;
matchTemplate.setHeader(cseqHeader);
boolean retval =
((SIPRequest) message).match((SIPRequest)matchTemplate);
System.out.println("match returned = " + retval);
cseq.setMethod(Request.SUBSCRIBE);
retval = ((SIPRequest) message).match((SIPRequest)matchTemplate);
System.out.println("match returned = " + retval);
}