优化sip消息
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package com.genersoft.iot.vmp.gb28181.utils;
|
||||
|
||||
import javax.sip.PeerUnavailableException;
|
||||
import javax.sip.SipFactory;
|
||||
import javax.sip.header.UserAgentHeader;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 生成header的工具类
|
||||
* @author lin
|
||||
*/
|
||||
public class HeaderUtils {
|
||||
|
||||
public static UserAgentHeader createUserAgentHeader(SipFactory sipFactory) throws PeerUnavailableException, ParseException {
|
||||
List<String> agentParam = new ArrayList<>();
|
||||
agentParam.add("WVP PRO");
|
||||
// TODO 添加版本信息以及日期
|
||||
return sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,16 @@ import gov.nist.javax.sip.address.AddressImpl;
|
||||
import gov.nist.javax.sip.address.SipUri;
|
||||
import gov.nist.javax.sip.header.Subject;
|
||||
|
||||
import javax.sip.PeerUnavailableException;
|
||||
import javax.sip.SipFactory;
|
||||
import javax.sip.header.FromHeader;
|
||||
import javax.sip.header.Header;
|
||||
import javax.sip.header.UserAgentHeader;
|
||||
import javax.sip.message.Request;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author panlinlin
|
||||
@@ -38,4 +45,25 @@ public class SipUtils {
|
||||
return uri.getUser();
|
||||
}
|
||||
|
||||
public static String getNewViaTag() {
|
||||
return "z9hG4bK" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static UserAgentHeader createUserAgentHeader(SipFactory sipFactory) throws PeerUnavailableException, ParseException {
|
||||
List<String> agentParam = new ArrayList<>();
|
||||
agentParam.add("WVP PRO");
|
||||
// TODO 添加版本信息以及日期
|
||||
return sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
|
||||
}
|
||||
|
||||
public static String getNewFromTag(){
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
|
||||
// return getNewTag();
|
||||
}
|
||||
|
||||
public static String getNewTag(){
|
||||
return String.valueOf(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user