本文整理汇总了Java中javax.sip.header.ContactHeader类的典型用法代码示例。如果您正苦于以下问题:Java ContactHeader类的具体用法?Java ContactHeader怎么用?Java ContactHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContactHeader类属于javax.sip.header包,在下文中一共展示了ContactHeader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createContactHeader
import javax.sip.header.ContactHeader; //导入依赖的package包/类
public ContactHeader createContactHeader() {
try {
String ipAddress = this.getIPAddress();
int port = this.getPort();
SipURI sipURI = new SipUri();
sipURI.setHost(ipAddress);
sipURI.setPort(port);
sipURI.setTransportParam(this.transport);
Contact contact = new Contact();
AddressImpl address = new AddressImpl();
address.setURI(sipURI);
contact.setAddress(address);
return contact;
} catch (Exception ex) {
InternalErrorHandler.handleException("Unexpected exception",logger);
return null;
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:20,代码来源:ListeningPointImpl.java
示例2: getHeadersToOmmitOnResponseCopy
import javax.sip.header.ContactHeader; //导入依赖的package包/类
private static Set<String> getHeadersToOmmitOnResponseCopy() {
if (HEADERS_TO_OMMIT_ON_RESPONSE_COPY == null) {
final Set<String> set = new HashSet<String>();
set.add(RouteHeader.NAME);
set.add(RecordRouteHeader.NAME);
set.add(ViaHeader.NAME);
set.add(CallIdHeader.NAME);
set.add(CSeqHeader.NAME);
set.add(ContactHeader.NAME);
set.add(FromHeader.NAME);
set.add(ToHeader.NAME);
set.add(ContentLengthHeader.NAME);
HEADERS_TO_OMMIT_ON_RESPONSE_COPY = Collections.unmodifiableSet(set);
}
return HEADERS_TO_OMMIT_ON_RESPONSE_COPY;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:TestCall.java
示例3: testMultipleContacts
import javax.sip.header.ContactHeader; //导入依赖的package包/类
public void testMultipleContacts() throws Exception {
Server server = new Server();
Client client = new Client();
client.sendMultipleContactRegistration();
Thread.sleep(1000);
Request serverLastRequestReceived = server.getLastRequestReceived();
assertNotNull(serverLastRequestReceived);
ListIterator<ContactHeader> iterator = serverLastRequestReceived.getHeaders(ContactHeader.NAME);
assertTrue(iterator.hasNext());
String first = iterator.next().getAddress().getURI().toString();
String second = iterator.next().getAddress().getURI().toString();
assertEquals("sip:[email protected]:5080", second);
assertEquals("sip:[email protected]:5070", first);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:19,代码来源:MultipleContactsTest.java
示例4: sendMultipleContactRegistration
import javax.sip.header.ContactHeader; //导入依赖的package包/类
public void sendMultipleContactRegistration() throws Exception {
Address fromAddress = addressFactory.createAddress("[email protected]:5070");
ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
CallIdHeader callId = provider.getNewCallId();
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.REGISTER);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
List via = Arrays.asList(((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader());
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
Request request = messageFactory.createRequest(requestURI, Request.REGISTER, callId, cSeq, from, to, via, maxForwards);
request.setRequestURI(requestURI);
request.addHeader(contactHeader1);
request.addHeader(contactHeader2);
ClientTransaction ctx = this.provider.getNewClientTransaction(request);
ctx.sendRequest();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:MultipleContactsTest.java
示例5: processResponse
import javax.sip.header.ContactHeader; //导入依赖的package包/类
public void processResponse(ResponseEvent responseEvent) {
try {
Response response = responseEvent.getResponse();
Dialog dialog = responseEvent.getDialog();
this.lastResponseTable.put(dialog, response);
ServerTransaction serverTransaction = (ServerTransaction)responseEvent.getClientTransaction().getApplicationData();
Request stRequest = serverTransaction.getRequest();
Response newResponse = this.messageFactory.createResponse(response.getStatusCode(),stRequest);
SipProvider provider = (SipProvider)responseEvent.getSource();
SipProvider peerProvider = this.getPeerProvider(provider);
ListeningPoint peerListeningPoint = peerProvider.getListeningPoint("udp");
ContactHeader peerContactHeader = ((ListeningPointExt)peerListeningPoint).createContactHeader();
newResponse.setHeader(peerContactHeader);
serverTransaction.sendResponse(newResponse);
} catch (Exception ex) {
ex.printStackTrace();
BackToBackUserAgentTest.fail("Unexpected exception");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:20,代码来源:BackToBackUserAgent.java
示例6: processInvite
import javax.sip.header.ContactHeader; //导入依赖的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);
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:DeliverRequestEventWithBadHeaderTest.java
示例7: sendInviteWithRPort
import javax.sip.header.ContactHeader; //导入依赖的package包/类
public void sendInviteWithRPort() throws Exception {
Address fromAddress = addressFactory.createAddress("[email protected]:5070");
ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
CallIdHeader callId = provider.getNewCallId();
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.INVITE);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
ViaHeader via = ((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader();
via.setRPort();
List vias = Arrays.asList(via);
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
Request request = messageFactory.createRequest(requestURI, Request.INVITE, callId, cSeq, from, to, vias, maxForwards);
System.out.println(request);
assertTrue(request.toString().indexOf("rport=") == -1);
request.setRequestURI(requestURI);
request.addHeader(contactHeader1);
request.addHeader(contactHeader2);
ClientTransaction ctx = this.provider.getNewClientTransaction(request);
ctx.sendRequest();
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:27,代码来源:ViaRPortTest.java
示例8: processInvite
import javax.sip.header.ContactHeader; //导入依赖的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");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:Shootist.java
示例9: processInvite
import javax.sip.header.ContactHeader; //导入依赖的package包/类
private void processInvite( RequestEvent re )
{
SipProvider provider = (SipProvider) re.getSource();
ServerTransaction st = re.getServerTransaction();
try {
if (st==null) st = provider.getNewServerTransaction( re.getRequest() );
Response r = messageFactory.createResponse( 100 , re.getRequest());
st.sendResponse( r );
r = messageFactory.createResponse( 180 , re.getRequest());
r.addHeader( (ContactHeader) contactHeader.clone() );
((ToHeader) r.getHeader("To")).setTag( "inv_res" );
st.sendResponse( r );
Thread.sleep( 500 );
r = messageFactory.createResponse( 200, re.getRequest() );
r.addHeader( (ContactHeader) contactHeader.clone() );
((ToHeader) r.getHeader("To")).setTag( "inv_res" );
st.sendResponse( r );
} catch (Throwable t) {
t.printStackTrace();
TestHarness.fail( "Throwable:" + t.getLocalizedMessage() );
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:Referrer.java
示例10: processInvite
import javax.sip.header.ContactHeader; //导入依赖的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");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:Shootist.java
示例11: createTiContact
import javax.sip.header.ContactHeader; //导入依赖的package包/类
/**
* Add a contact for the TI.
*/
public ContactHeader createTiContact() throws Exception {
try {
ContactHeader contact = tiHeaderFactory.createContactHeader();
// JvB: getIPAddress may return null!
String ip = tiSipProvider.getSipStack().getIPAddress();
if (ip == null) {
ListeningPoint lp = (ListeningPoint) tiSipProvider
.getSipStack().getListeningPoints().next();
ip = lp.getIPAddress();
}
SipURI srcSipURI = tiAddressFactory.createSipURI(null, ip);
srcSipURI.setPort(tiSipProvider.getListeningPoint("udp").getPort());
srcSipURI.setTransportParam("udp");
Address address = tiAddressFactory.createAddress(srcSipURI);
address.setDisplayName("TI Contact");
contact.setAddress(address);
return contact;
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(false);
throw ex;
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:MessageFlowHarness.java
示例12: createRiContact
import javax.sip.header.ContactHeader; //导入依赖的package包/类
/**
* Add a contact for the TI.
*/
public ContactHeader createRiContact() throws TckInternalError {
try {
ContactHeader contact = riHeaderFactory.createContactHeader();
// BUG reported by Ben Evans (Open Cloud):
// Should be using RI's address factory here, not TI's.
ListeningPoint lp = riSipProvider.getListeningPoints()[0];
SipURI srcSipURI = riAddressFactory.createSipURI(null, lp
.getIPAddress());
srcSipURI.setPort(lp.getPort());
srcSipURI.setTransportParam(lp.getTransport());
Address address = riAddressFactory.createAddress(srcSipURI);
address.setDisplayName("RI Contact");
contact.setAddress(address);
return contact;
} catch (Exception ex) {
throw new TckInternalError(ex.getMessage());
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:MessageFlowHarness.java
示例13: processRegister
import javax.sip.header.ContactHeader; //导入依赖的package包/类
public void processRegister(RequestEvent requestEvent,
ServerTransaction serverTransactionId) {
Request request = requestEvent.getRequest();
ContactHeader contact = (ContactHeader) request.getHeader(ContactHeader.NAME);
SipURI contactUri = (SipURI) contact.getAddress().getURI();
FromHeader from = (FromHeader) request.getHeader(FromHeader.NAME);
SipURI fromUri = (SipURI) from.getAddress().getURI();
// DataServer.getUserData().setContact(fromUri.toString(),
// new UserData.UserAddress(contactUri.getHost(),contactUri.getPort()));
// Verify AUTHORIZATION !!!!!!!!!!!!!!!!
try {
DigestServerAuthenticationWWWHelper dsam = new DigestServerAuthenticationWWWHelper();
if (!dsam.doAuthenticatePlainTextPassword(request, DataServer.getUserData().getPassword(fromUri.getUser()))) {
Response challengeResponse = mMessageFactory.createResponse(
Response.UNAUTHORIZED, request);
dsam.generateChallenge(mHeaderFactory, challengeResponse, "nist.gov");
mSipProvider.getNewServerTransaction(request).sendResponse(challengeResponse);
return;
}
Response response = mMessageFactory.createResponse(Response.OK, request);
ServerTransaction serverTransaction = mSipProvider.getNewServerTransaction(request);
serverTransaction.sendResponse(response);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:34,代码来源:SipServer.java
示例14: setRemoteTarget
import javax.sip.header.ContactHeader; //导入依赖的package包/类
/**
* Add a route list extacted from the contact list of the incoming message.
*
* @param contactList
* -- contact list extracted from the incoming message.
*
*/
protected void setRemoteTarget(ContactHeader contact) {
this.remoteTarget = contact.getAddress();
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug(
"Dialog.setRemoteTarget: " + this.remoteTarget);
logger.logStackTrace();
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:18,代码来源:SIPDialog.java
示例15: addRoute
import javax.sip.header.ContactHeader; //导入依赖的package包/类
/**
* Add a Route list extracted from a SIPRequest to this Dialog.
*
* @param sipRequest
*/
public synchronized void addRoute(SIPRequest sipRequest) {
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug(
"setContact: dialogState: " + this + "state = "
+ this.getState());
}
if (this.dialogState == CONFIRMED_STATE
&& SIPRequest.isTargetRefresh(sipRequest.getMethod())) {
this.doTargetRefresh(sipRequest);
}
if (this.dialogState == CONFIRMED_STATE
|| this.dialogState == TERMINATED_STATE) {
return;
}
// put the contact header from the incoming request into
// the route set. JvB: some duplication here, ref. doTargetRefresh
ContactList contactList = sipRequest.getContactHeaders();
if (contactList != null) {
this.setRemoteTarget((ContactHeader) contactList.getFirst());
}
// Fix for issue #225: mustn't learn Route set from mid-dialog requests
if (sipRequest.getToTag() != null)
return;
// Incoming Request has the route list
RecordRouteList rrlist = sipRequest.getRecordRouteHeaders();
// Add the route set from the incoming response in reverse
// order
if (rrlist != null) {
this.addRoute(rrlist);
} else {
// Set the rotue list to the last seen route list.
this.routeList = new RouteList();
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:45,代码来源:SIPDialog.java
示例16: logResponse
import javax.sip.header.ContactHeader; //导入依赖的package包/类
/**
* Log a response received at this message channel. This is used for processing incoming
* responses to a client transaction.
*
* @param receptionTime is the time at which the response was received.
* @param status is the processing status of the message.
*
*/
public void logResponse(SIPResponse sipResponse, long receptionTime, String status) {
int peerport = getPeerPort();
if (peerport == 0 && sipResponse.getContactHeaders() != null) {
ContactHeader contact = (ContactHeader) sipResponse.getContactHeaders().getFirst();
peerport = ((AddressImpl) contact.getAddress()).getPort();
}
String from = getPeerAddress().toString() + ":" + peerport;
String to = this.getHost() + ":" + getPort();
this.getSIPStack().serverLogger.logMessage(sipResponse, from, to, status, false,
receptionTime);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:21,代码来源:MessageChannel.java
示例17: sendInviteOK
import javax.sip.header.ContactHeader; //导入依赖的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();
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:35,代码来源:Shootme.java
示例18: sendInviteOK
import javax.sip.header.ContactHeader; //导入依赖的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();
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:36,代码来源:Shootme.java
示例19: sendInviteOK
import javax.sip.header.ContactHeader; //导入依赖的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();
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:Shootme.java
示例20: processPrack
import javax.sip.header.ContactHeader; //导入依赖的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());
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:33,代码来源:UdpPrackTimeoutTest.java
注:本文中的javax.sip.header.ContactHeader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论