本文整理汇总了Java中javax.sip.message.Message.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getHeader方法的具体用法?Java Message.getHeader怎么用?Java Message.getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sip.message.Message
的用法示例。
在下文中一共展示了Message.getHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachScSpecifics
import javax.sip.message.Message; //导入方法依赖的package包/类
/**
* Attaches to <tt>message</tt> headers and object params that we'd like to
* be present in absolutely all messages we create (like for example the
* user agent header, the contact header or the provider message object
* tag).
*
* @param message the message that we'd like to tag
* @return returns a reference to <tt>message</tt> for convenience reasons.
*/
private Message attachScSpecifics(Message message)
{
SipApplicationData.setApplicationData(message,
SipApplicationData.KEY_SERVICE, this.protocolProvider);
//the jain-sip semantics allow the application to "forget" attaching a
//To tag to a response so let's make sure we do this here
if(message instanceof Response)
{
FromHeader from = (FromHeader)message.getHeader(From.NAME);
String fromTag = (from == null) ? null : from.getTag();
Response response = (Response)message;
//if there's a from tag and this is a non-failure response,
//that still doesn't have a To tag, then we are adding a to tag.
if(fromTag != null && fromTag.trim().length() > 0
&& response.getStatusCode() > 100
&& response.getStatusCode() < 300)
{
attachToTag(response, null);
}
}
//add a contact header.
attachContactHeader(message);
// If this is a SIP request (other than ACK) then let's try to
// pre-authenticate it.
if(message instanceof Request
&& !Request.ACK.equals(((Request)message).getMethod()))
{
preAuthenticateRequest((Request)message);
}
// User Agent
UserAgentHeader userAgentHeader
= protocolProvider.getSipCommUserAgentHeader();
//beware: if UA header generation failed for some reason, we don't want
//it to mess up the entire request.
if (userAgentHeader != null)
{
message.setHeader(userAgentHeader);
}
return message;
}
示例2: inviteCompleted
import javax.sip.message.Message; //导入方法依赖的package包/类
/**
* Notifies this <tt>MethodProcessorListener</tt> that the procedure for
* handling an INVITE or reINVITE SIP <tt>Request</tt> has completed and it
* is appropriate to determine whether the remote <tt>CallPeer</tt> is a
* conference focus.
*
* @param sourceCallPeer the <tt>CallPeer</tt> with which the procedure for
* handling an INVITE or reINVITE SIP <tt>Request</tt> has finished
* negotiating
* @param remoteMessage the remote SIP <tt>Message</tt> which was received,
* processed and which prompted sending a specific local SIP
* <tt>Message</tt>
* @param localMessage the local SIP <tt>Message</tt> which was sent to the
* <tt>CallPeer</tt> as part of the processing of its remote SIP
* <tt>Message</tt>
*/
private void inviteCompleted(
CallPeerSipImpl sourceCallPeer,
Message remoteMessage,
Message localMessage)
{
ContactHeader contactHeader
= (ContactHeader) remoteMessage.getHeader(ContactHeader.NAME);
boolean conferenceFocus = false;
if (contactHeader != null)
{
/*
* The javadoc says that ContactHeader#getParameter(String) will
* return an empty string for a flag but it does not and returns
* null.
*/
Iterator<?> parameterNameIter
= contactHeader.getParameterNames();
while (parameterNameIter.hasNext())
if ("isfocus"
.equalsIgnoreCase(parameterNameIter.next().toString()))
{
conferenceFocus = true;
break;
}
}
sourceCallPeer.addCallPeerListener(callPeerStateListener);
sourceCallPeer.setConferenceFocus(conferenceFocus);
if (sourceCallPeer.isConferenceFocus() && sourceCallPeer.getState() ==
CallPeerState.CONNECTED)
{
ConferenceSubscriberSubscription subscription
= new ConferenceSubscriberSubscription(
sourceCallPeer);
try
{
subscriber.subscribe(subscription);
}
catch (OperationFailedException ofe)
{
logger
.error(
"Failed to create or send a conference subscription to "
+ sourceCallPeer, ofe);
}
}
}
示例3: attachScSpecifics
import javax.sip.message.Message; //导入方法依赖的package包/类
/**
* Attaches to <tt>message</tt> headers and object params that we'd like to
* be present in absolutely all messages we create (like for example the
* user agent header, the contact header or the provider message object
* tag).
*
* @param message the message that we'd like to tag
* @return returns a reference to <tt>message</tt> for convenience reasons.
*/
private Message attachScSpecifics(Message message)
{
SipApplicationData.setApplicationData(message,
SipApplicationData.KEY_SERVICE, this.protocolProvider);
//the jain-sip semantics allow the application to "forget" attaching a
//To tag to a response so let's make sure we do this here
if(message instanceof Response)
{
FromHeader from = (FromHeader)message.getHeader(From.NAME);
String fromTag = (from == null) ? null : from.getTag();
Response response = (Response)message;
//if there's a from tag and this is a non-failure response,
//that still doesn't have a To tag, then we are adding a to tag.
if(fromTag != null && fromTag.trim().length() > 0
&& response.getStatusCode() > 100
&& response.getStatusCode() < 300)
{
attachToTag(response, null);
}
}
//add a contact header.
attachContactHeader(message);
// If this is a SIP request (other than ACK) then let's try to
// pre-authenticate it.
if(message instanceof Request
&& !Request.ACK.equals(((Request)message).getMethod()))
{
preAuthenticateRequest((Request)message);
}
// User Agent
UserAgentHeader userAgentHeader
= protocolProvider.getSipCommUserAgentHeader();
//beware: if UA header generation failed for some reason, we don't want
//it to mess up the entire request.
if (userAgentHeader != null)
{
message.setHeader(userAgentHeader);
}
// attach any custom headers pre-configured for the account
ConfigHeaders.attachConfigHeaders(message, protocolProvider);
return message;
}