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


Java SipException类代码示例

本文整理汇总了Java中javax.sip.SipException的典型用法代码示例。如果您正苦于以下问题:Java SipException类的具体用法?Java SipException怎么用?Java SipException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SipException类属于javax.sip包,在下文中一共展示了SipException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import javax.sip.SipException; //导入依赖的package包/类
@Override
public void send(SIPRequest ackRequest) throws SipException, IOException {
    hop = sipStack.getNextHop(ackRequest);
    if (hop == null)
    throw new SipException("No route!");
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG))
        logger.logDebug("hop = " + hop);
    ListeningPointImpl lp = (ListeningPointImpl) sipProvider
            .getListeningPoint(hop.getTransport());
    if (lp == null)
        throw new SipException(
                "No listening point for this provider registered at "
                        + hop);
    InetAddress inetAddress = InetAddress.getByName(hop.getHost());
    MessageChannel messageChannel = lp.getMessageProcessor()
            .createMessageChannel(inetAddress, hop.getPort());
                messageChannel.sendMessage(ackRequest);
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:19,代码来源:SIPDialog.java

示例2: resendAck

import javax.sip.SipException; //导入依赖的package包/类
/**
 * Resend the last ack.
 */
public void resendAck() throws SipException {
    // Check for null.

    if (this.getLastAckSent() != null) {
        if (getLastAckSent().getHeader(TimeStampHeader.NAME) != null
                && sipStack.generateTimeStampHeader) {
            TimeStamp ts = new TimeStamp();
            try {
                ts.setTimeStamp(System.currentTimeMillis());
                getLastAckSent().setHeader(ts);
            } catch (InvalidArgumentException e) {

            }
        }
        this.sendAck(getLastAckSent(), false);
    } else {
    	if(logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)){
    		logger.logDebug("SIPDialog::resendAck:lastAck sent is NULL hence not resending ACK");
    	}
    }

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

示例3: createCancel

import javax.sip.SipException; //导入依赖的package包/类
/**
 * @see SIPClientTransaction#createCancel()
 */
@Override
public Request createCancel() throws SipException {
  SIPRequest originalRequest = this.getOriginalRequest();
  if (originalRequest == null)
    throw new SipException("Bad state " + getState());
  if (!originalRequest.getMethod().equals(Request.INVITE))
    throw new SipException("Only INIVTE may be cancelled");

  if (originalRequest.getMethod().equalsIgnoreCase(Request.ACK))
    throw new SipException("Cannot Cancel ACK!");
  else {
    SIPRequest cancelRequest = originalRequest.createCancelRequest();
    cancelRequest.setInviteTransaction(this);
    return cancelRequest;
  }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:20,代码来源:SIPClientTransactionImpl.java

示例4: createErrorAck

import javax.sip.SipException; //导入依赖的package包/类
private final Request createErrorAck() throws SipException, ParseException {
  SIPRequest originalRequest = this.getOriginalRequest();
  if (originalRequest == null)
    throw new SipException("bad state " + getState());
  if (!isInviteTransaction()) {
    throw new SipException("Can only ACK an INVITE!");
  } else if (lastResponse == null) {
    throw new SipException("bad Transaction state");
  } else if (lastResponse.getStatusCode() < 200) {
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
      logger.logDebug("lastResponse = " + lastResponse);
    }
    throw new SipException("Cannot ACK a provisional response!");
  }
  return originalRequest.createErrorAck((To) lastResponse.getTo());
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:SIPClientTransactionImpl.java

示例5: encodeBody

import javax.sip.SipException; //导入依赖的package包/类
public StringBuilder encodeBody(StringBuilder encoding) {

//        StringBuilder encoding = new StringBuilder();
        /*
         * no need to check for the presence of icid-value. According to the
         * spec above this is a mandatory field. if it does not exist, then we
         * should throw an exception
         *
         * JvB 26/5: fix for issue #159, check for quotes around icid value
         * 
         * Aayush: 29th November 2011 : Added fix for P-Charging-Vector header's parameters to accept quoted string values.
         */
       gov.nist.core.NameValue nv = getNameValue( ParameterNamesIms.ICID_VALUE );
       		if(nv!=null)
        this.parameters.encode(encoding);
			else
				try {
					throw new SipException("icid-value is mandatory");
				} catch (SipException e) {
					e.printStackTrace();
					
				}

        return encoding;
    }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:26,代码来源:PChargingVector.java

示例6: getNewClientTransaction

import javax.sip.SipException; //导入依赖的package包/类
public ClientTransaction getNewClientTransaction(Request request)
        throws TransactionUnavailableException {
  Hop hop = null;
  try {
      hop = sipStack.getNextHop((SIPRequest) request);
      if (hop == null)
          throw new TransactionUnavailableException(
                  "Cannot resolve next hop -- transaction unavailable");
  } catch (SipException ex) {
      throw new TransactionUnavailableException(
              "Cannot resolve next hop -- transaction unavailable", ex);
  }
  SIPClientTransaction newClientTransaction = createClientTransaction(request, hop);
  sipStack.addTransaction(newClientTransaction);
  return newClientTransaction;
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:SipProviderImpl.java

示例7: processResponse

import javax.sip.SipException; //导入依赖的package包/类
public void processResponse(ResponseEvent responseEvent) {
    Response response = responseEvent.getResponse();
    int code = response.getStatusCode();
    if (code == 180) {
        try {

            o_received180 = true;
            Request cancel = responseEvent.getClientTransaction().createCancel();
            ClientTransaction cancelTX = provider.getNewClientTransaction(cancel);
            cancelTX.sendRequest();
            System.out.println("Send CANCEL:\n" + cancel);
            o_sentCancel = true;

        } catch (SipException e) {
            e.printStackTrace();
            doFail(doMessage(e));
        }
    } else if (code == 200) {
        System.out.println("Receive Cancel200");
        o_receiver200Cancel = true;
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:NoAutoDialogTest.java

示例8: sendRequest

import javax.sip.SipException; //导入依赖的package包/类
/**
 * Sends a request with the specified request and transport.
 * @param request   The request packet.
 * @param transport The transport protocol used.
 * @param dialog    The dialog for a persistent transaction.
 *                  Leave it <code>null</code> if no dialog is associated with this request.
 * @throws javax.sip.SipException Unable to communicate.
 */
@SuppressWarnings("unchecked")
private void sendRequest(Request request, String transport, Dialog dialog) throws SipException {
    for (Iterator sipProviders = sipStack.getSipProviders(); sipProviders.hasNext(); ) {
        SipProvider provider = (SipProvider) sipProviders.next();
        if (provider.getListeningPoint(transport) != null) {
            Log.debug("Sending packet:  \n" + request.toString() + "\n========\n");
            
            ClientTransaction transaction = provider.getNewClientTransaction(request);
            if (dialog != null)
                dialog.sendRequest(transaction);
            else
                transaction.sendRequest();
            
            return;
        }
    }
    
    Log.debug("SimpleSession(" + this.jid.getNode() + "):  No SipProvider found for that transport!");
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:SimpleSession.java

示例9: sendRequest

import javax.sip.SipException; //导入依赖的package包/类
/**
 * Sends a request with the specified request and transport.
 * @param request   The request packet.
 * @param transport The transport protocol used.
 * @param dialog    The dialog for a persistent transaction.
 *                  Leave it <code>null</code> if no dialog is associated with this request.
    * @throws javax.sip.SipException Unable to communicate.
 */
@SuppressWarnings("unchecked")
   private void sendRequest(Request request, String transport, Dialog dialog) throws SipException {
	for (Iterator sipProviders = sipStack.getSipProviders(); sipProviders.hasNext(); ) {
		SipProvider provider = (SipProvider) sipProviders.next();
		if (provider.getListeningPoint(transport) != null) {
			Log.debug("Sending packet:  \n" + request.toString() + "\n========\n");
			
			ClientTransaction transaction = provider.getNewClientTransaction(request);
			if (dialog != null)
				dialog.sendRequest(transaction);
			else
				transaction.sendRequest();
			
			return;
		}
	}
	
	Log.debug("SimpleSession(" + this.jid.getNode() + "):  No SipProvider found for that transport!");
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:28,代码来源:SimpleSession.java

示例10: sendInitialInvite

import javax.sip.SipException; //导入依赖的package包/类
/**
 * @param localMediaPort
 * @throws ParseException
 * @throws PeerUnavailableException
 * @throws InvalidArgumentException
 * @throws TransactionUnavailableException
 * @throws SipException
 */
private void sendInitialInvite(String recipient) throws ParseException,
		PeerUnavailableException, InvalidArgumentException,
		TransactionUnavailableException, SipException {
	BrokerFactory.getLoggingBroker().logDebug("Calling " + recipient+" at "+remoteHost);
	
	ContentTypeHeader contentTypeHeader = null;
	//content type should be application/sdp (not applications)
	//reported by Oleg Shevchenko (Miratech)
	contentTypeHeader = sipFactory.createHeaderFactory()
			.createContentTypeHeader("application", "sdp");

	String sdpContent = "v=0\n" + "o="+sipHandler.getUsername()+" 0 0 IN IP4 "
			+ SipHandler.getInstance().getLocalHost() + "\n" + "s=-\n"
			+ "c=IN IP4 " + SipHandler.getInstance().getLocalHost() + "\n"
			+ "t=0 0\n" + "m=audio " + localMediaPort
			+ " RTP/AVP 4 3 0 5 6 8 15 18\n" + "a=sendrecv\n"
			+ "a=rtpmap:101 telephone-event/8000 \n"
			+ "a=fmtp:101 64\n"
			+ "a=rtpmap:0 PCMU/8000\n";
	BrokerFactory.getLoggingBroker().logDebug("sdpContent ="+sdpContent);

	sipHandler.sendRequest(recipient, Request.INVITE, sdpContent, contentTypeHeader);

}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:33,代码来源:SipOutboundCall.java

示例11: sayCancel

import javax.sip.SipException; //导入依赖的package包/类
private void sayCancel(Dialog dialog) throws CommunicationsException {
    if (dialog.isServer()) {

        throw new CommunicationsException(
                "Cannot cancel a server transaction");
    }
    ClientTransaction clientTransaction = (ClientTransaction) dialog
            .getFirstTransaction();
    try {
        Request cancel = clientTransaction.createCancel();
        ClientTransaction cancelTransaction = sipManCallback.sipProvider
                .getNewClientTransaction(cancel);
        cancelTransaction.sendRequest();
    }
    catch (SipException ex) {

        throw new CommunicationsException(
                "Failed to send the CANCEL request", ex);
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:21,代码来源:CallProcessing.java

示例12: addLast

import javax.sip.SipException; //导入依赖的package包/类
public void addLast(Header header) throws SipException, NullPointerException {
    if (header == null)
        throw new NullPointerException("null arg!");

    try {
        this.attachHeader((SIPHeader) header, false, false);
    } catch (SIPDuplicateHeaderException ex) {
        throw new SipException("Cannot add header - header already exists");
    }

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

示例13: addFirst

import javax.sip.SipException; //导入依赖的package包/类
public void addFirst(Header header) throws SipException, NullPointerException {

        if (header == null)
            throw new NullPointerException("null arg!");

        try {
            this.attachHeader((SIPHeader) header, false, true);
        } catch (SIPDuplicateHeaderException ex) {
            throw new SipException("Cannot add header - header already exists");
        }

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

示例14: createRequest

import javax.sip.SipException; //导入依赖的package包/类
public Request createRequest(String method) throws SipException {

        if (method.equals(Request.ACK) || method.equals(Request.PRACK)) {
            throw new SipException(
                    "Invalid method specified for createRequest:" + method);
        }
        if (lastResponseTopMostVia != null)
            return this.createRequest(method, this.lastResponseTopMostVia
                    .getTransport());
        else
            throw new SipException("Dialog not yet established -- no response!");
    }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:13,代码来源:SIPDialog.java

示例15: createPrack

import javax.sip.SipException; //导入依赖的package包/类
public Request createPrack(Response relResponse)
        throws DialogDoesNotExistException, SipException {

    if (this.getState() == null
            || this.getState().equals(DialogState.TERMINATED))
        throw new DialogDoesNotExistException(
                "Dialog not initialized or terminated");

    if ((RSeq) relResponse.getHeader(RSeqHeader.NAME) == null) {
        throw new SipException("Missing RSeq Header");
    }

    try {
        SIPResponse sipResponse = (SIPResponse) relResponse;
        SIPRequest sipRequest = this.createRequest(Request.PRACK,
                sipResponse.getTopmostVia().getTransport());
        String toHeaderTag = sipResponse.getTo().getTag();
        sipRequest.setToTag(toHeaderTag);
        RAck rack = new RAck();
        RSeq rseq = (RSeq) relResponse.getHeader(RSeqHeader.NAME);
        rack.setMethod(sipResponse.getCSeq().getMethod());
        rack.setCSequenceNumber((int) sipResponse.getCSeq().getSeqNumber());
        rack.setRSequenceNumber(rseq.getSeqNumber());
        sipRequest.setHeader(rack);
        if (this.proxyAuthorizationHeader != null) {
            sipRequest.addHeader(proxyAuthorizationHeader);
        }
        return (Request) sipRequest;
    } catch (Exception ex) {
        InternalErrorHandler.handleException(ex);
        return null;
    }

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


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