本文整理汇总了Java中javax.sip.header.ContentTypeHeader类的典型用法代码示例。如果您正苦于以下问题:Java ContentTypeHeader类的具体用法?Java ContentTypeHeader怎么用?Java ContentTypeHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentTypeHeader类属于javax.sip.header包,在下文中一共展示了ContentTypeHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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() );
}
示例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()");
}
}
示例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;
}
示例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();
}
}
示例11: getContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public ContentTypeHeader getContentTypeHeader() {
return contentTypeHeader;
}
示例12: setContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
/**
* @param contentTypeHeader the contentTypeHeader to set
*/
public void setContentTypeHeader(ContentTypeHeader contentTypeHeader) {
this.contentTypeHeader = contentTypeHeader;
}
示例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;
}
示例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);
}
示例15: getContentTypeHeader
import javax.sip.header.ContentTypeHeader; //导入依赖的package包/类
public ContentTypeHeader getContentTypeHeader() {
return multipartMimeContentTypeHeader;
}