当前位置: 首页>>代码示例>>Java>>正文


Java CSeq类代码示例

本文整理汇总了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);
    }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:28,代码来源:SIPResponse.java

示例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);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:32,代码来源:UDPMessageChannel.java

示例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);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:31,代码来源:SCTPMessageChannel.java

示例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);
        }
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:14,代码来源:SIPRequest.java

示例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();

    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:39,代码来源:SIPMessage.java

示例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;

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:44,代码来源:SIPDialog.java

示例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);
	}
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:62,代码来源:NioTcpMessageChannel.java

示例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);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:62,代码来源:TCPMessageChannel.java

示例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);


}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:32,代码来源:MatchTest.java


注:本文中的gov.nist.javax.sip.header.CSeq类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。