本文整理汇总了Java中javax.sip.header.ContentTypeHeader类的典型用法代码示例。如果您正苦于以下问题:Java ContentTypeHeader类的具体用法?Java ContentTypeHeader怎么用?Java ContentTypeHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentTypeHeader类属于javax.sip.header包,在下文中一共展示了ContentTypeHeader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setContent
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
* Set the message content after converting the given object to a String.
*
* @param content -- content to set.
* @param contentTypeHeader -- content type header corresponding to content.
*/
public void setContent(Object content, ContentTypeHeader contentTypeHeader)
throws ParseException {
if (content == null)
throw new NullPointerException("null content");
this.setHeader(contentTypeHeader);
this.messageContent = null;
this.messageContentBytes = null;
this.messageContentObject = null;
if (content instanceof String) {
this.messageContent = (String) content;
} else if (content instanceof byte[]) {
this.messageContentBytes = (byte[]) content;
} else
this.messageContentObject = content;
computeContentLength(content);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:26,代码来源:SIPMessage.java
示例2: init
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
private boolean init(String data)
{
if (super.init() == false)
return false;
try {
ContentTypeHeader contentTypeHeader;
contentTypeHeader = headerFactory
.createContentTypeHeader("application", "text/plain");
request.setContent(data, contentTypeHeader);
return true;
}
catch (Exception e)
{
logger.error("Error adding content: ", e);
}
return false;
}
开发者ID:lmangani,项目名称:Reaper,代码行数:18,代码来源:NotifyMessage.java
示例3: init
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
private boolean init(String data)
{
if (super.init() == false)
return false;
try {
ContentTypeHeader contentTypeHeader;
contentTypeHeader = headerFactory
.createContentTypeHeader("application", "vq-rtcpxr");
request.setContent(data, contentTypeHeader);
return true;
}
catch (Exception e)
{
logger.error("Error adding content: ", e);
}
return false;
}
开发者ID:lmangani,项目名称:Reaper,代码行数:18,代码来源:PublishMessage.java
示例4: sendInitialInvite
import javax.sip.header.ContentTypeHeader; //导入依赖的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
示例5: parseBodyPart
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
private ContentImpl parseBodyPart(String bodyPart) throws ParseException {
String headers[] = null;
String bodyContent;
// if a empty line starts the body it means no headers are present
if (bodyPart.startsWith("\n") || bodyPart.startsWith("\r\n")) {
bodyContent = bodyPart;
} else {
// limit the number of crlf (new lines) we split on, only split the header from
// the body and don't split on any crlf in the body
String[] nextPartSplit = bodyPart.split("\r?\n\r?\n", 2);
bodyContent = bodyPart;
if (nextPartSplit.length == 2) {
// since we aren't completely sure the data is a header let's test the first one
String potentialHeaders[] = nextPartSplit[0].split("\r?\n");
if (potentialHeaders[0].indexOf(":") > 0) {
headers = potentialHeaders;
bodyContent = nextPartSplit[1];
}
}
}
ContentImpl content = new ContentImpl(bodyContent);
if (headers != null) {
for (String partHeader : headers) {
Header header = headerFactory.createHeader(partHeader);
if (header instanceof ContentTypeHeader) {
content.setContentTypeHeader((ContentTypeHeader) header);
} else if (header instanceof ContentDispositionHeader) {
content.setContentDispositionHeader((ContentDispositionHeader) header);
} else {
content.addExtensionHeader(header);
}
}
}
return content;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:40,代码来源:MultipartMimeContentImpl.java
示例6: equals
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public boolean equals(Object other) {
if (other instanceof ContentTypeHeader) {
final ContentTypeHeader o = (ContentTypeHeader) other;
return this.getContentType().equalsIgnoreCase( o.getContentType() )
&& this.getContentSubType().equalsIgnoreCase( o.getContentSubType() )
&& equalParameters( o );
}
return false;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:10,代码来源:ContentType.java
示例7: testAgainstRIMsgContent
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
private void testAgainstRIMsgContent( Message tiMsg, Message riMsg ) {
// Test equality using RI definition of equals
assertEquals( riMsg.getHeader( ContentLengthHeader.NAME ), tiMsg.getHeader( ContentLengthHeader.NAME ) );
assertEquals( riMsg.getHeader( ContentTypeHeader.NAME ), tiMsg.getHeader( ContentTypeHeader.NAME ) );
assertEquals( riMsg.getContent(), tiMsg.getContent() );
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:8,代码来源:MessageFactoryTest.java
示例8: testCharset
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public void testCharset() {
try{
Request request = tiMessageFactory.createRequest(
"MESSAGE sip:127.0.0.1 SIP/2.0\r\n"+
"Via: SIP/2.0/TCP 127.0.0.1:5060;rport=5060;branch=z9hG4bKd2c87858eb0a7a09becc7a115c608d27\r\n"+
"CSeq: 2 BYE\r\n"+
"Call-ID: [email protected]\r\n"+
"From: \"The Master Blaster\" <sip:[email protected]>;tag=12345\r\n"+
"To: \"The Little Blister\" <sip:[email protected]>;tag=2955\r\n"+
"Max-Forwards: 70\r\n"+
"Content-Type: text/plain;charset=ISO-8859-1\r\n" +
"Content-Length: 0\r\n"+
"\r\n"
);
// JvB: in UTF-8 these character would be encoded as multiple bytes
byte[] content = "��".getBytes( "ISO-8859-1" );
request.setContent( new String(content,"ISO-8859-1"),
(ContentTypeHeader) request.getHeader(ContentTypeHeader.NAME) );
assertEquals( 2, request.getRawContent().length );
} catch (Exception t) {
t.printStackTrace();
fail( "ParseException", t );
} finally {
logTestCompleted("testCharset()");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:MessageFactoryTest.java
示例9: MakeRequest
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
*
* @param sipManager - SipManager object
* @param to - To identifies receiver IP
* @param message Message that should be send
* @return Return SIP Message.
* @throws ParseException
* @throws InvalidArgumentException
*/
public Request MakeRequest(SipManager sipManager, String to, String message) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
sipManager.setCseqNumber((long)sipManager.getCseqNumber()+1l);
Address fromNameAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
FromHeader fromHeader = sipManager.headerFactory.createFromHeader(fromNameAddress, "SyMPHOnY");
URI toAddress = sipManager.addressFactory.createURI(to);
Address toNameAddress = sipManager.addressFactory.createAddress(toAddress);
ToHeader toHeader = sipManager.headerFactory.createToHeader(toNameAddress, null);
URI requestURI = sipManager.addressFactory.createURI(to);
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
CallIdHeader callIdHeader = sipManager.sipProvider.getNewCallId();
CSeqHeader cSeqHeader = sipManager.headerFactory.createCSeqHeader(sipManager.getCseqNumber(),Request.MESSAGE);
MaxForwardsHeader maxForwards = sipManager.headerFactory
.createMaxForwardsHeader(70);
Request request = sipManager.messageFactory.createRequest(requestURI,
Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
toHeader, viaHeaders, maxForwards);
SupportedHeader supportedHeader = sipManager.headerFactory
.createSupportedHeader("replaces, outbound");
request.addHeader(supportedHeader);
SipURI routeUri = sipManager.addressFactory.createSipURI(null,
SipManager.proxyIp);
routeUri.setTransportParam(SipManager.transport);
routeUri.setLrParam();
routeUri.setPort(SipManager.proxyPort);
Address routeAddress = sipManager.addressFactory
.createAddress(routeUri);
RouteHeader route = sipManager.headerFactory
.createRouteHeader(routeAddress);
request.addHeader(route);
ContentTypeHeader contentTypeHeader = sipManager.headerFactory
.createContentTypeHeader("text", "plain");
request.setContent(message, contentTypeHeader);
System.out.println(request);
return request;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:48,代码来源:MessageMessage.java
示例10: setSdp
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
void setSdp(String sdpContent) {
try {
ContentTypeHeader contentTypeHeader;
contentTypeHeader = headerFactory
.createContentTypeHeader("application", "sdp");
getMessage().setContent(sdpContent, contentTypeHeader);
}
catch (Exception e)
{
e.printStackTrace();
}
}
开发者ID:lmangani,项目名称:Reaper,代码行数:13,代码来源:SipMessage.java
示例11: getContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public ContentTypeHeader getContentTypeHeader() {
return contentTypeHeader;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:4,代码来源:ContentImpl.java
示例12: setContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
* @param contentTypeHeader the contentTypeHeader to set
*/
public void setContentTypeHeader(ContentTypeHeader contentTypeHeader) {
this.contentTypeHeader = contentTypeHeader;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:7,代码来源:ContentImpl.java
示例13: createAckRequest
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
* Creates a default ACK SIPRequest message for this original request. Note that the
* defaultACK SIPRequest does not include the content of the original SIPRequest. If
* responseToHeader is null then the toHeader of this request is used to construct the ACK.
* Note that tag fields are just copied from the original SIP Request. Added by Jeff Keyser.
*
* @param responseToHeader To header to use for this request.
*
* @return A SIPRequest with an ACK method.
*/
public SIPRequest createAckRequest(To responseToHeader) {
// SIPRequest newRequest;
// Iterator headerIterator;
// SIPHeader nextHeader;
// cloning instead of iterating through headers so that lazy parsers don't have to parse the messages fully
// to create ACK requests
SIPRequest newRequest = (SIPRequest) this.clone();
// newRequest = new SIPRequest();
// newRequest.setRequestLine((RequestLine) this.requestLine.clone());
newRequest.setMethod(Request.ACK);
// Ack and cancel do not get ROUTE headers.
// Route header for ACK is assigned by the
// Dialog if necessary.
newRequest.removeHeader(RouteHeader.NAME);
// Remove proxy auth header.
// Assigned by the Dialog if necessary.
newRequest.removeHeader(ProxyAuthorizationHeader.NAME);
// Adding content is responsibility of user.
newRequest.removeContent();
// Content type header is removed since
// content length is 0.
newRequest.removeHeader(ContentTypeHeader.NAME);
// The CSeq header field in the
// ACK MUST contain the same value for the
// sequence number as was present in the
// original request, but the method parameter
// MUST be equal to "ACK".
try{
newRequest.getCSeq().setMethod(Request.ACK);
} catch (ParseException e) {
}
if (responseToHeader != null) {
newRequest.setTo(responseToHeader);
}
// CONTACT header does not apply for ACK requests.
newRequest.removeHeader(ContactHeader.NAME);
newRequest.removeHeader(ExpiresHeader.NAME);
ViaList via = newRequest.getViaHeaders();
// Bug reported by Gianluca Martinello
// The ACK MUST contain a single Via header field,
// and this MUST be equal to the top Via header
// field of the original
// request.
if(via != null && via.size() > 1) {
for(int i = 2; i < via.size(); i++) {
via.remove(i);
}
}
if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
newRequest.setHeader(MessageFactoryImpl.getDefaultUserAgentHeader());
}
return newRequest;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:67,代码来源:SIPRequest.java
示例14: MultipartMimeContentImpl
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
* Creates a default content list.
*/
public MultipartMimeContentImpl(ContentTypeHeader contentTypeHeader) {
this.multipartMimeContentTypeHeader = contentTypeHeader;
this.boundary = contentTypeHeader.getParameter(BOUNDARY);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:9,代码来源:MultipartMimeContentImpl.java
示例15: getContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public ContentTypeHeader getContentTypeHeader() {
return multipartMimeContentTypeHeader;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:4,代码来源:MultipartMimeContentImpl.java
示例16: sendNotify
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
private void sendNotify( int code, String reason )
throws SipException, ParseException
{
/*
* NOTIFY requests MUST contain a "Subscription-State" header with a
* value of "active", "pending", or "terminated". The "active" value
* indicates that the subscription has been accepted and has been
* authorized (in most cases; see section 5.2.). The "pending" value
* indicates that the subscription has been received, but that
* policy information is insufficient to accept or deny the
* subscription at this time. The "terminated" value indicates that
* the subscription is not active.
*/
Request notifyRequest = dialog.createRequest( "NOTIFY" );
// Initial state is pending, second time we assume terminated (Expires==0)
String state = SubscriptionStateHeader.PENDING;
if (code>100 && code<200) {
state = SubscriptionStateHeader.ACTIVE;
} else if (code>=200) {
state = SubscriptionStateHeader.TERMINATED;
}
SubscriptionStateHeader sstate = headerFactory.createSubscriptionStateHeader( state );
if (state == SubscriptionStateHeader.TERMINATED) {
sstate.setReasonCode("noresource");
}
notifyRequest.addHeader(sstate);
notifyRequest.setHeader(referEvent);
Address address = addressFactory.createAddress("Referee <sip:127.0.0.1>");
((SipURI)address.getURI()).setPort( mySipProvider.getListeningPoint(transport).getPort() );
((SipURI)address.getURI()).setTransportParam(transport);
ContactHeader contactHeader = headerFactory.createContactHeader(address);
notifyRequest.setHeader(contactHeader);
// notifyRequest.setHeader(routeHeader);
ClientTransaction ct2 = mySipProvider.getNewClientTransaction(notifyRequest);
ContentTypeHeader ct = headerFactory.createContentTypeHeader("message","sipfrag");
ct.setParameter( "version", "2.0" );
notifyRequest.setContent( "SIP/2.0 " + code + ' ' + reason, ct );
// Let the other side know that the tx is pending acceptance
//
dialog.sendRequest(ct2);
logger.info("NOTIFY Branch ID " +
((ViaHeader)notifyRequest.getHeader(ViaHeader.NAME)).getParameter("branch"));
logger.info("Dialog " + dialog);
logger.info("Dialog state after NOTIFY: " + dialog.getState());
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:53,代码来源:Referee.java
示例17: createFactoriesAndHeaders
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void createFactoriesAndHeaders(Map<String, Object> parameters, SipComponent component) throws Exception {
headerFactory = sipFactory.createHeaderFactory();
addressFactory = sipFactory.createAddressFactory();
setMessageFactory(sipFactory.createMessageFactory());
fromHeader = component.resolveAndRemoveReferenceParameter(parameters, "fromHeader", FromHeader.class, null);
if (fromHeader == null) {
createFromHeader();
}
if (!presenceAgent) {
toHeader = component.resolveAndRemoveReferenceParameter(parameters, "toHeader", ToHeader.class, null);
if (toHeader == null) {
createToHeader();
}
}
viaHeaders = component.resolveAndRemoveReferenceParameter(parameters, "viaHeaders", List.class, null);
if (viaHeaders == null) {
createViaHeaders();
}
contentTypeHeader = component.resolveAndRemoveReferenceParameter(parameters, "contentTypeHeader", ContentTypeHeader.class, null);
if (contentTypeHeader == null) {
createContentTypeHeader();
}
callIdHeader = component.resolveAndRemoveReferenceParameter(parameters, "callIdHeader", CallIdHeader.class, null);
maxForwardsHeader = component.resolveAndRemoveReferenceParameter(parameters, "maxForwardsHeader", MaxForwardsHeader.class, null);
if (maxForwardsHeader == null) {
createMaxForwardsHeader();
}
// Optional Headers
eventHeader = component.resolveAndRemoveReferenceParameter(parameters, "eventHeader", EventHeader.class, null);
if (eventHeader == null) {
createEventHeader();
}
contactHeader = component.resolveAndRemoveReferenceParameter(parameters, "contactHeader", ContactHeader.class, null);
if (contactHeader == null) {
createContactHeader();
}
expiresHeader = component.resolveAndRemoveReferenceParameter(parameters, "expiresHeader", ExpiresHeader.class, null);
if (expiresHeader == null) {
createExpiresHeader();
}
extensionHeader = component.resolveAndRemoveReferenceParameter(parameters, "extensionHeader", ExtensionHeader.class, null);
}
开发者ID:HydAu,项目名称:Camel,代码行数:48,代码来源:SipConfiguration.java
示例18: getContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public ContentTypeHeader getContentTypeHeader() {
return contentTypeHeader;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:SipConfiguration.java
示例19: setContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
* A custom Header object containing message content details. Must implement the type javax.sip.header.ContentTypeHeader
*/
public void setContentTypeHeader(ContentTypeHeader contentTypeHeader) {
this.contentTypeHeader = contentTypeHeader;
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:SipConfiguration.java
示例20: MakeRequest
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
*
* @param sipManager - SipManager object
* @param to - identifies receiver IP
* @param message is message that should be send
* @return
* @throws ParseException
* @throws InvalidArgumentException
*/
public Request MakeRequest(SipManager sipManager, String to, String message) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
sipManager.setCseqNumber((long)sipManager.getCseqNumber()+1l);
//SipURI from = sipManager.addressFactory.createSipURI(sipManager.getSipProfile().getSipUserName(), sipManager.getSipProfile().getLocalEndpoint());
//Address fromNameAddress = sipManager.addressFactory.createAddress(from);
Address fromNameAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
// fromNameAddress.setDisplayName(sipUsername);
FromHeader fromHeader = sipManager.headerFactory.createFromHeader(fromNameAddress, "SyMPHOnY");
URI toAddress = sipManager.addressFactory.createURI(to);
Address toNameAddress = sipManager.addressFactory.createAddress(toAddress);
// toNameAddress.setDisplayName(username);
ToHeader toHeader = sipManager.headerFactory.createToHeader(toNameAddress, null);
URI requestURI = sipManager.addressFactory.createURI(to);
// requestURI.setTransportParam("udp");
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
CallIdHeader callIdHeader = sipManager.sipProvider.getNewCallId();
CSeqHeader cSeqHeader = sipManager.headerFactory.createCSeqHeader(sipManager.getCseqNumber(),Request.MESSAGE);
MaxForwardsHeader maxForwards = sipManager.headerFactory
.createMaxForwardsHeader(70);
Request request = sipManager.messageFactory.createRequest(requestURI,
Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
toHeader, viaHeaders, maxForwards);
SupportedHeader supportedHeader = sipManager.headerFactory
.createSupportedHeader("replaces, outbound");
request.addHeader(supportedHeader);
SipURI routeUri = sipManager.addressFactory.createSipURI(null,
SipManager.proxyIp);
routeUri.setTransportParam(SipManager.transport);
routeUri.setLrParam();
routeUri.setPort(SipManager.proxyPort);
Address routeAddress = sipManager.addressFactory
.createAddress(routeUri);
RouteHeader route = sipManager.headerFactory
.createRouteHeader(routeAddress);
request.addHeader(route);
ContentTypeHeader contentTypeHeader = sipManager.headerFactory
.createContentTypeHeader("text", "plain");
request.setContent(message, contentTypeHeader);
System.out.println(request);
return request;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:60,代码来源:MessageMessage.java
注:本文中的javax.sip.header.ContentTypeHeader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论