本文整理汇总了Java中javax.sip.message.Response.addHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Response.addHeader方法的具体用法?Java Response.addHeader怎么用?Java Response.addHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sip.message.Response
的用法示例。
在下文中一共展示了Response.addHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
try {
Dialog dialog = st.getDialog();
Response response = protocolObjects.messageFactory.createResponse(
Response.OK, request);
((ToHeader) response.getHeader(ToHeader.NAME))
.setTag(((ToHeader) request.getHeader(ToHeader.NAME))
.getTag());
Address address = protocolObjects.addressFactory
.createAddress("Shootme <sips:" + myAddress + ":" + myPort
+ ">");
ContactHeader contactHeader = protocolObjects.headerFactory
.createContactHeader(address);
response.addHeader(contactHeader);
st.sendResponse(response);
} catch (Exception ex) {
logger.error("unexpected exception",ex);
TlsTest.fail("unexpected exception");
}
}
示例2: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
/**
* Process the invite request.
*/
public void processInvite(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
this.sawInvite = true;
try {
Response okResponse = messageFactory.createResponse(
Response.OK, request);
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
ToHeader toHeader = (ToHeader) okResponse
.getHeader(ToHeader.NAME);
toHeader.setTag("4321"); // Application is supposed to set.
okResponse.addHeader(contactHeader);
sipProvider.sendResponse(okResponse); // Send it through the
// Provider.
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
}
}
示例3: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
try {
Dialog dialog = st.getDialog();
Response response = protocolObjects.messageFactory.createResponse(
Response.OK, request);
((ToHeader) response.getHeader(ToHeader.NAME))
.setTag(((ToHeader) request.getHeader(ToHeader.NAME))
.getTag());
Address address = protocolObjects.addressFactory
.createAddress("Shootme <sip:" + myAddress + ":" + myPort
+ ">");
ContactHeader contactHeader = protocolObjects.headerFactory
.createContactHeader(address);
response.addHeader(contactHeader);
st.sendResponse(response);
} catch (Exception ex) {
logger.error("unexpected exception",ex);
SctpTest.fail("unexpected exception");
}
}
示例4: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
try {
this.reInviteReceivedCount++;
Dialog dialog = st.getDialog();
logger.info("shootist received RE INVITE. Sending BUSY_HERE");
assertEquals("Dialog state must in confirmed state ",DialogState.CONFIRMED,dialog.getState());
Thread.sleep(300);
Response response = protocolObjects.messageFactory.createResponse(Response.BUSY_HERE,
request);
((ToHeader) response.getHeader(ToHeader.NAME)).setTag(((ToHeader) request
.getHeader(ToHeader.NAME)).getTag());
Address address = protocolObjects.addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = protocolObjects.headerFactory
.createContactHeader(address);
response.addHeader(contactHeader);
st.sendResponse(response);
assertEquals("Dialog state must be in confirmed state ",DialogState.CONFIRMED,dialog.getState());
ReInviteInfoAckOverlapTest.assertEquals("Dialog for reinvite must match original dialog",
dialog, this.dialog);
} catch (Exception ex) {
logger.error("unexpected exception", ex);
ReInviteInfoAckOverlapTest.fail("unexpected exception");
}
}
示例5: sendInviteOK
import javax.sip.message.Response; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
try {
logger.info("sendInviteOK: " + inviteTid);
if (inviteTid.getState() != TransactionState.COMPLETED) {
logger.info("shootme: Dialog state before OK: "
+ inviteTid.getDialog().getState());
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
Response okResponse = messageFactory.createResponse(Response.OK,
request);
ListeningPoint lp = sipProvider.getListeningPoint(transport);
int myPort = lp.getPort();
((ToHeader)okResponse.getHeader(ToHeader.NAME)).setTag(toTag);
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
okResponse.addHeader(contactHeader);
inviteTid.sendResponse(okResponse);
logger.info("shootme: Dialog state after OK: "
+ inviteTid.getDialog().getState());
TestCase.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
} else {
logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例6: sendInviteOK
import javax.sip.message.Response; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
try {
logger.info("sendInviteOK: " + inviteTid);
if (inviteTid.getState() != TransactionState.COMPLETED) {
logger.info("shootme: Dialog state before OK: "
+ inviteTid.getDialog().getState());
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
Response okResponse = messageFactory.createResponse(Response.OK,
request);
ListeningPoint lp = sipProvider.getListeningPoint(transport);
int myPort = lp.getPort();
((ToHeader)okResponse.getHeader(ToHeader.NAME)).setTag(toTag);
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
okResponse.addHeader(contactHeader);
inviteTid.sendResponse(okResponse);
logger.info("shootme: Dialog state after OK: "
+ inviteTid.getDialog().getState());
TestCase.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
} else {
logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例7: sendInviteOK
import javax.sip.message.Response; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
try {
logger.info("sendInviteOK: " + inviteTid);
if (inviteTid.getState() == TransactionState.PROCEEDING) {
logger.info("shootme: Dialog state before OK: " + inviteTid.getDialog().getState());
System.err.println("shootme: Dialog state before OK: " + inviteTid.getDialog().getState());
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
Response okResponse = messageFactory.createResponse(Response.OK, request);
ListeningPoint lp = sipProvider.getListeningPoint(transport);
int myPort = lp.getPort();
((ToHeader) okResponse.getHeader(ToHeader.NAME)).setTag(toTag);
Address address = addressFactory.createAddress("Shootme <sip:" + myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory.createContactHeader(address);
okResponse.addHeader(contactHeader);
inviteTid.sendResponse(okResponse);
logger.info("shootme: Dialog state after OK: " + inviteTid.getDialog().getState());
TestCase.assertEquals(DialogState.CONFIRMED, inviteTid.getDialog().getState());
} else {
logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
System.err.println("sentInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例8: processPrack
import javax.sip.message.Response; //导入方法依赖的package包/类
private void processPrack(RequestEvent requestEvent,
ServerTransaction serverTransactionId) {
prackRequestReceived = true;
try {
logger.info("shootme: got an PRACK! ");
logger.info("Dialog State = " + dialog.getState());
/**
* JvB: First, send 200 OK for PRACK
*/
Request prack = requestEvent.getRequest();
Response prackOk = messageFactory.createResponse(200, prack);
serverTransactionId.sendResponse(prackOk);
/**
* Send a 200 OK response to complete the 3 way handshake for the
* INIVTE.
*/
Response response = messageFactory.createResponse(200,
inviteRequest);
ToHeader to = (ToHeader) response.getHeader(ToHeader.NAME);
to.setTag(this.toTag);
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
response.addHeader(contactHeader);
inviteTid.sendResponse(response);
} catch (Exception ex) {
TestHarness.fail(ex.getMessage());
}
}
示例9: sendInviteOK
import javax.sip.message.Response; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
try {
logger.info("sendInviteOK: " + inviteTid);
if (inviteTid.getState() != TransactionState.COMPLETED) {
logger.info("shootme: Dialog state before OK: "
+ inviteTid.getDialog().getState());
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
Response okResponse = messageFactory.createResponse(Response.OK,
request);
ListeningPoint lp = sipProvider.getListeningPoint(transport);
int myPort = lp.getPort();
((ToHeader)okResponse.getHeader(ToHeader.NAME)).setTag(toTag);
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ";transport=" + transport+ ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
okResponse.addHeader(contactHeader);
inviteTid.sendResponse(okResponse);
logger.info("shootme: Dialog state after OK: "
+ inviteTid.getDialog().getState());
TestCase.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
} else {
logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例10: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
/**
* Process the invite request.
*/
public void processInvite(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
logger.info("shootme: got an Invite sending RINGING");
// logger.info("shootme: " + request);
Response response = messageFactory.createResponse(180, request);
ToHeader toHeader = (ToHeader) response
.getHeader(ToHeader.NAME);
toHeader.setTag("4321"); // Application is supposed to set.
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
response.addHeader(contactHeader);
ServerTransaction st = requestEvent.getServerTransaction();
if (st == null) {
st = sipProvider.getNewServerTransaction(request);
logger.info("Created a new server transaction for "
+ request.getMethod() + " serverTransaction = "
+ st);
}
inviteTid = st;
dialog = st.getDialog();
st.sendResponse(response);
} catch (Exception ex) {
logger.error(ex);
fail(unexpectedException);
}
}
示例11: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
/**
* Process the invite request.
*/
public void processInvite(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
if ( serverTransaction == null) {
serverTransaction = sipProvider.getNewServerTransaction(request);
}
Response okResponse = messageFactory.createResponse(Response.OK,
request);
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
toHeader.setTag("4321"); // Application is supposed to set.
okResponse.addHeader(contactHeader);
serverTransaction.sendResponse(okResponse); // Send it through the transaction layer.
} catch (Exception ex) {
ex.printStackTrace();
fail("Unexpected exception ");
}
}
示例12: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
/**
* Process the invite request.
*/
public void processInvite(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
logger.info("shootme: got an Invite sending Trying");
// logger.info("shootme: " + request);
ServerTransaction st = requestEvent.getServerTransaction();
if (st == null) {
logger.info("null server tx -- getting a new one");
st = sipProvider.getNewServerTransaction(request);
}
logger.info("getNewServerTransaction : " + st);
String txId = ((ViaHeader)request.getHeader(ViaHeader.NAME)).getBranch();
this.serverTxTable.put(txId, st);
// Create the 100 Trying response.
Response response = messageFactory.createResponse(Response.TRYING,
request);
ListeningPoint lp = sipProvider.getListeningPoint(transport);
int myPort = lp.getPort();
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
// Add a random sleep to stagger the two OK's for the benifit of implementations
// that may not be too good about handling re-entrancy.
int timeToSleep = (int) ( Math.random() * 1000);
Thread.sleep(timeToSleep);
st.sendResponse(response);
Response ringingResponse = messageFactory.createResponse(Response.RINGING,
request);
ContactHeader contactHeader = headerFactory.createContactHeader(address);
response.addHeader(contactHeader);
ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME);
String toTag = new Integer(new Random().nextInt()).toString();
toHeader.setTag(toTag);
if ( sendRinging ) {
ringingResponse.addHeader(contactHeader);
st.sendResponse(ringingResponse);
}
Dialog dialog = st.getDialog();
dialog.setApplicationData(st);
this.inviteSeen = true;
timer.schedule(new MyTimerTask(requestEvent,st,toTag), this.delay);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
}
}
示例13: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
/**
* Process the invite request.
*/
public void processInvite(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
logger.info("shootme: got an Invite sending Trying");
// logger.info("shootme: " + request);
ServerTransaction st = requestEvent.getServerTransaction();
if (st == null) {
logger.info("null server tx -- getting a new one");
st = sipProvider.getNewServerTransaction(request);
}
logger.info("getNewServerTransaction : " + st);
String txId = ((ViaHeader)request.getHeader(ViaHeader.NAME)).getBranch();
this.serverTxTable.put(txId, st);
// Create the 100 Trying response.
Response response = messageFactory.createResponse(Response.TRYING,
request);
ListeningPoint lp = sipProvider.getListeningPoint(transport);
int myPort = lp.getPort();
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
// Add a random sleep to stagger the two OK's for the benifit of implementations
// that may not be too good about handling re-entrancy.
int timeToSleep = (int) ( Math.random() * 1000);
Thread.sleep(timeToSleep);
st.sendResponse(response);
Response ringingResponse = messageFactory.createResponse(Response.RINGING,
request);
ContactHeader contactHeader = headerFactory.createContactHeader(address);
response.addHeader(contactHeader);
ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME);
String toTag;
if ( ((ToHeader) ringingResponse.getHeader(ToHeader.NAME)).getTag() == null ) {
toTag = new Integer(new Random().nextInt()).toString();
toHeader.setTag(toTag);
} else {
toTag = ((ToHeader) ringingResponse.getHeader(ToHeader.NAME)).getTag();
}
if ( sendRinging ) {
ringingResponse.addHeader(contactHeader);
st.sendResponse(ringingResponse);
}
Dialog dialog = st.getDialog();
dialog.setApplicationData(st);
this.inviteSeen = true;
this.sendInviteOK(requestEvent,st,toTag);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
}
}
示例14: processInvite
import javax.sip.message.Response; //导入方法依赖的package包/类
/**
* Process the invite request.
*/
public void processInvite(RequestEvent requestEvent,
ServerTransaction serverTransaction) {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request request = requestEvent.getRequest();
try {
serverTransaction = sipProvider.getNewServerTransaction(request);
dialog = (DialogExt) sipProvider.getNewDialog(serverTransaction);
dialog.disableSequenceNumberValidation();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Response okResponse = messageFactory.createResponse(Response.OK,
request);
FromHeader from = (FromHeader) okResponse.getHeader(FromHeader.NAME);
from.removeParameter("tag");
Address address = addressFactory.createAddress("Shootme <sip:"
+ myAddress + ":" + myPort + ">");
ContactHeader contactHeader = headerFactory
.createContactHeader(address);
ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
toHeader.setTag("4321"); // Application is supposed to set.
FromHeader fromHeader = (FromHeader)okResponse.getHeader(FromHeader.NAME);
fromHeader.setTag("12345");
okResponse.addHeader(contactHeader);
serverTransaction.sendResponse(okResponse);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
}
}
示例15: processNotify
import javax.sip.message.Response; //导入方法依赖的package包/类
public synchronized void processNotify(RequestEvent requestEvent,
ServerTransaction serverTransactionId) {
SipProvider provider = (SipProvider) requestEvent.getSource();
Request notify = requestEvent.getRequest();
try {
logger.info("subscriber: got a notify count " + this.count++);
if (serverTransactionId == null) {
logger.info("subscriber: null TID.");
serverTransactionId = provider.getNewServerTransaction(notify);
}
Dialog dialog = serverTransactionId.getDialog();
logger.info("Dialog = " + dialog);
if (dialog != null) {
logger.info("Dialog State = " + dialog.getState());
}
Response response = messageFactory.createResponse(200, notify);
// SHOULD add a Contact
ContactHeader contact = (ContactHeader) contactHeader.clone();
((SipURI) contact.getAddress().getURI()).setParameter("id", "sub");
response.addHeader(contact);
logger.info("Transaction State = " + serverTransactionId.getState());
serverTransactionId.sendResponse(response);
if (dialog != null) {
logger.info("Dialog State = " + dialog.getState());
}
SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
.getHeader(SubscriptionStateHeader.NAME);
// Subscription is terminated?
String state = subscriptionState.getState();
if (state.equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
dialog.delete();
} else {
logger.info("Subscriber: state now " + state);
}
this.notifySeen = true;
} catch (Exception ex) {
ex.printStackTrace();
logger.error("Unexpected exception", ex);
fail("Unexpected exception");
}
}