📄 siptransaction.java
字号:
/* * This file was derived from libdissipate, an open source SIP library. The original file * was modified on 1/23/2001. Please see * http://www.div8.net/dissipate for more information. * * Copyright (c) 2000 Billy Biggs <bbiggs@div8.net> * * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public * License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * *//** * class SipTransaction * * This code has been generated using C2J++ * C2J++ is based on Chris Laffra's C2J (laffra@watson.ibm.com) * Read general disclaimer distributed with C2J++ before using this code * For information about C2J++, send mail to Ilya_Tilevich@ibi.com */package org.mitre.jsip;import java.util.ArrayList;import java.util.Date;import java.util.Timer;import java.util.TimerTask;import org.mitre.jsip.event.*;public class SipTransaction extends Object{ // class variables static final int RemoteRequest = 0; static final int LocalRequest = 1; static final int None = 2; private SipCall parent; private SipMessage requestmessage; private ArrayList responseList; private SipStatus laststatus; private int seqnum; private SipCallMember remote; private SipUri contacturi; private int direction; private boolean cancelled; // use a single Timer to schedule retransmission checks private static Timer retransmissionTimer; // instances of this class that execute requests will track if retransmissions are necessary private TimerTask retransmissionTimerTask; // how often we should run the check (in ms) private static final int RETRANS_TIMER_CHECK = 10000; /** * SipTransaction * @param seqn * @param farend * @param call */ public SipTransaction(int seqn, SipCallMember farEnd, SipCall call) { responseList = new ArrayList(); parent = call; requestmessage = null; direction = None; remote = farEnd; seqnum = seqn; cancelled = false; } /** * getCallMember * @return SipCallMember * */ public SipCallMember getCallMember() { return remote; } /** * getCSeq * @return String */ public String getCSeq() { String cseq = String.valueOf(seqnum) + " " + Sip.getMethodString( requestmessage.getMethod() ); return cseq; } /** * getDirection * @return Direction */ public int getDirection() { return direction; } /** * getSeqNum * @return int */ public int getSeqNum() { return seqnum; } /** * getStatus * @return SipStatus */ public SipStatus getStatus() { return laststatus; } /** * wasCancelled * @return bool */ public boolean wasCancelled() { return cancelled; } /** * getRequest * @return SipMessage * */ public SipMessage getRequest() { return requestmessage; } public void sendResponse( SipStatus status ) { sendResponse( status, null, null ); } /** * sendResponse */ public void sendResponse( SipStatus status, String body, MimeContentType bodytype) { SipMessage response = new SipMessage(); setStatus( status ); responseList.add( response ); response.setType( SipMessage.Response ); response.setStatus( status ); response.setViaList( requestmessage.getViaList() ); response.insertHeader( SipHeader.From, remote.getUri().nameAddr() ); response.insertHeader( SipHeader.CSeq, getCSeq() ); if (bodytype != null) { response.insertHeader( SipHeader.Content_Type, bodytype.type() ); } response.setBody( body ); parent.sendResponse( response ); } /** * cancelRequest */ public void cancelRequest() { cancelRequest( null, null ); } public void cancelRequest( String body, MimeContentType bodytype) { requestmessage.setMethod( Sip.CANCEL ); sendRequest( Sip.CANCEL, body, bodytype); } /** * getFinalMessageBody * @return String */ public String getFinalMessageBody() { int index = responseList.size(); if ( index > 0 ) { SipMessage sm = (SipMessage)responseList.get( index - 1 ); return sm.messageBody(); } return null; } /** * getFinalContentType * @return MimeContentType */ public MimeContentType getFinalContentType() { int index = responseList.size(); if ( index > 0 ) { SipMessage sm = (SipMessage)responseList.get( index - 1 ); return new MimeContentType( sm.getHeaderData( SipHeader.Content_Type ) ); } return null; } /** * getFinalContactList * @return SipUriList */ public SipUriList getFinalContactList() { int index = responseList.size(); if ( index > 0 ) { SipMessage sm = (SipMessage)responseList.get( index - 1 ); return sm.getContactList(); } return null; } /** * getFinalWWWAuthString * @return String */ public String getFinalWWWAuthString() { int index = responseList.size(); if ( index > 0 ) { SipMessage sm = (SipMessage)responseList.get( index - 1 ); return sm.getHeaderData( SipHeader.WWW_Authenticate ); } return null; } /** * getFinalProxyAuthString * @return String */ public String getFinalProxyAuthString() { int index = responseList.size(); if ( index > 0 ) { SipMessage sm = (SipMessage)responseList.get( index - 1 ); return sm.getHeaderData( SipHeader.Proxy_Authenticate ); } return null; } /** * getRequestMessageBody * @return String */ public String getRequestMessageBody() { return requestmessage.messageBody(); } /** * getRequestMessageContentType * @return MimeContentType */ public MimeContentType getRequestMessageContentType() { if( requestmessage.hasHeader( SipHeader.Content_Type ) ) { return new MimeContentType( requestmessage.getHeaderData( SipHeader.Content_Type ) ); } return null; } /** * statusUpdated */ //private void statusUpdated() { //SipCall.statusUpdated(); //*** LOOK AT *** //} /** * setStatus * @param stat */ private void setStatus(SipStatus stat)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -