- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用以下代码时遇到错误。
我已经包含了 Sip 所需的所有 jar ;但是,我仍然不明白为什么会发生这个错误。你能给我解释一下吗?
我的代码类是:
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Properties;
import java.util.Random;
import javax.sip.DialogTerminatedEvent;
import javax.sip.IOExceptionEvent;
import javax.sip.ListeningPoint;
import javax.sip.RequestEvent;
import javax.sip.ResponseEvent;
import javax.sip.SipFactory;
import javax.sip.SipListener;
import javax.sip.SipProvider;
import javax.sip.SipStack;
import javax.sip.TimeoutEvent;
import javax.sip.TransactionTerminatedEvent;
import javax.sip.address.Address;
import javax.sip.address.AddressFactory;
import javax.sip.header.CSeqHeader;
import javax.sip.header.CallIdHeader;
import javax.sip.header.ContactHeader;
import javax.sip.header.FromHeader;
import javax.sip.header.HeaderFactory;
import javax.sip.header.MaxForwardsHeader;
import javax.sip.header.ToHeader;
import javax.sip.header.ViaHeader;
import javax.sip.message.MessageFactory;
import javax.sip.message.Request;
import javax.swing.JFrame;
public class SipClient extends JFrame implements SipListener
{
SipFactory sipFactory; // Used to access the SIP API.
SipStack sipStack; // The SIP stack.
SipProvider sipProvider; // Used to send SIP messages.
MessageFactory messageFactory; // Used to create SIP message factory.
HeaderFactory headerFactory; // Used to create SIP headers.
AddressFactory addressFactory; // Used to create SIP URIs.
ListeningPoint listeningPoint; // SIP listening IP address/port.
Properties properties; // Other properties.
String ip; // The local IP address.
int port = 6060; // The local port.
String protocol = "udp"; // The local protocol (UDP).
int tag = (new Random()).nextInt(); // The local tag.
Address contactAddress; // The contact address.
ContactHeader contactHeader; // The contact header.
public SipClient()
{
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN- BEGIN:initComponents
private void initComponents() {
scrollPane = new javax.swing.JScrollPane();
textArea = new javax.swing.JTextArea();
buttonRegisterStateless = new javax.swing.JButton();
buttonRegisterStatefull = new javax.swing.JButton();
buttonInvite = new javax.swing.JButton();
buttonBye = new javax.swing.JButton();
textField = new javax.swing.JTextField();
this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SIP Client");
setLocationByPlatform(true);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
onOpen(evt);
}
});
textArea.setEditable(false);
textArea.setColumns(20);
textArea.setRows(5);
scrollPane.setViewportView(textArea);
buttonRegisterStateless.setText("Reg (SL)");
buttonRegisterStateless.setEnabled(true);
buttonRegisterStateless.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onRegisterStateless(evt);
}
});
buttonRegisterStatefull.setText("Reg (SF)");
buttonRegisterStatefull.setEnabled(true);
buttonRegisterStatefull.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onRegisterStatefull(evt);
}
});
buttonInvite.setText("Invite");
buttonInvite.setEnabled(true);
buttonInvite.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onInvite(evt);
}
});
buttonBye.setText("Bye");
buttonBye.setEnabled(true);
buttonBye.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
onBye(evt);
}
});
textField.setText("");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G)
.addComponent(scrollPane)
.addGroup(layout.createSequentialGroup()
.addComponent(buttonRegisterStateless, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonRegisterStatefull, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonInvite, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonBye, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 2, Short.MAX_VALUE))
.addComponent(textField))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonRegisterStateless)
.addComponent(buttonInvite)
.addComponent(buttonBye)
.addComponent(buttonRegisterStatefull))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void onOpen(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_onOpen
try
{
this.ip=InetAddress.getLocalHost().getHostAddress();
System.out.println(ip);
this.sipFactory=SipFactory.getInstance();
this.sipFactory.setPathName("gov.nist");
this.properties=new Properties();
this.properties.setProperty("javax.sip.STACK_NAME", "myStack");
// Create the SIP stack.
this.sipStack = this.sipFactory.createSipStack(this.properties);
// Create the SIP message factory.
this.messageFactory = this.sipFactory.createMessageFactory();
// Create the SIP header factory.
this.headerFactory = this.sipFactory.createHeaderFactory();
// Create the SIP address factory.
this.addressFactory = this.sipFactory.createAddressFactory();
// Create the SIP listening point and bind it to the local IP address, port and protocol.
this.listeningPoint = this.sipStack.createListeningPoint(this.ip, this.port, this.protocol);
// Create the SIP provider.
this.sipProvider = this.sipStack.createSipProvider(this.listeningPoint);
// Add our application as a SIP listener.
this.sipProvider.addSipListener(this);
// Create the contact address used for all SIP messages.
System.out.println("Local address: " + this.ip +" : "+ this.port + "\n");
this.contactAddress = this.addressFactory.createAddress("sip: "+ this.ip +" : "+ this.port);
// Create the contact header used for all SIP messages.
this.contactHeader = this.headerFactory.createContactHeader(contactAddress);
// Display the local IP address and port in the text area.
System.out.println("Local address: " + this.ip +" : "+ this.port + "\n");
}
catch(Exception e)
{
e.printStackTrace();
}
}//GEN-LAST:event_onOpen
private void onRegisterStateless(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onRegisterStateless
try {
// Get the destination address from the text field.
Address addressTo = addressFactory.createAddress(textField.getText());
// Create the request URI for the SIP message.
javax.sip.address.URI requestURI = addressTo.getURI();
// Create the SIP message headers.
// The "Via" headers.
ArrayList viaHeaders = new ArrayList();
ViaHeader viaHeader = headerFactory.createViaHeader(ip, port, "udp", null);
viaHeaders.add(viaHeader);
// The "Max-Forwards" header.
MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);
// The "Call-Id" header.
CallIdHeader callIdHeader = sipProvider.getNewCallId();
// The "CSeq" header.
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1L,"REGISTER");
// The "From" header.
FromHeader fromHeader = headerFactory.createFromHeader(contactAddress, String.valueOf(tag));
// The "To" header.
ToHeader toHeader = headerFactory.createToHeader(addressTo, null);
// Create the REGISTER request.
Request request = messageFactory.createRequest(
requestURI,
"REGISTER",
callIdHeader,
cSeqHeader,
fromHeader,
toHeader,
viaHeaders,
maxForwardsHeader);
// Add the "Contact" header to the request.
request.addHeader(contactHeader);
// Send the request statelessly through the SIP provider.
sipProvider.sendRequest(request);
// Display the message in the text area.
textArea.append(
"Request sent:\n" + request.toString() + "\n\n");
}
catch(Exception e) {
// If an error occurred, display the error.
textArea.append("Request sent failed: " + e.getMessage() + "\n");
}
}//GEN-LAST:event_onRegisterStateless
private void onRegisterStatefull(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onRegisterStatefull
// A method called when you click on the "Reg (SF)" button.
}//GEN-LAST:event_onRegisterStatefull
private void onInvite(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onInvite
// A method called when you click on the "Invite" button.
}//GEN-LAST:event_onInvite
private void onBye(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onBye
// A method called when you click on the "Bye" button.
}//GEN-LAST:event_onBye
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SipClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new SipClient().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonBye;
private javax.swing.JButton buttonInvite;
private javax.swing.JButton buttonRegisterStatefull;
private javax.swing.JButton buttonRegisterStateless;
private javax.swing.JScrollPane scrollPane;
private javax.swing.JTextArea textArea;
private javax.swing.JTextField textField;
// End of variables declaration//GEN-END:variables
public void processRequest(RequestEvent requestEvent) {
// A method called when you receive a SIP request.
}
public void processResponse(ResponseEvent responseEvent) {
// A method called when you receive a SIP request.
}
public void processTimeout(TimeoutEvent timeoutEvent) {
// A method called when a SIP operation times out.
}
public void processIOException(IOExceptionEvent exceptionEvent) {
// A method called when a SIP operation results in an I/O error.
}
public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) {
// A method called when a SIP transaction terminates.
}
public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {
// A method called when a SIP dialog terminates.
}
}
我也包含了 org.apache.log4j
jar,但我仍然收到以下错误:
javax.sip.PeerUnavailableException: The Peer SIP Stack: gov.nist.javax.sip.SipStackImpl could not be instantiated. Ensure the Path Name has been set.
at javax.sip.SipFactory.createStack(SipFactory.java:324)
at javax.sip.SipFactory.createSipStack(SipFactory.java:152)
at ServerClasses.sc.SipClient.onOpen(SipClient.java:169)
at ServerClasses.sc.SipClient.access$0(SipClient.java:159)
at ServerClasses.sc.SipClient$1.windowOpened(SipClient.java:77)
at java.awt.Window.processWindowEvent(Unknown Source)
at javax.swing.JFrame.processWindowEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: gov.nist.javax.sip.SipStackImpl
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at javax.sip.SipFactory.createStack(SipFactory.java:305)
... 29 more
请帮我解决这个问题。我是 SIP 编程新手。
最佳答案
您需要 jain-sip-api 和 jain-sip-ri jar。通过查看错误,您缺少 ri jar。您可以从此处的存档中获取 jar https://jsip.ci.cloudbees.com/job/jsip/lastSuccessfulBuild/artifact/trunk/jain-sip-1.2.2370.tar.gz
关于java - 出现错误 javax.sip.PeerUnavailableException : The Peer SIP Stack: gov. nist.javax.sip.SipStackImpl 无法实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31073428/
我已经从 nist 网站下载了 NIST 统计测试套件 2.1.2 版。该软件包包含一个 makefile。如何在windows上编译工程(makefile)? 最佳答案 因为我遇到了同样的问题,
为了阅读 NIST sphere 格式文件,我尝试安装从 here 下载的 NIST SPHERE 软件,但我遇到了一些错误: make[2]: Entering directory `/home/i
我正在使用 NIST 软件。该工具(用 C 语言编写)具有交互模式。它获取一个输入文件,询问用户一些关于测试类型和参数的问题,然后运行测试。我想在多个文件上运行它,所以我想在 Python 中自动化整
我目前正在考虑使用 NIST .Net 项目并将其包含到我的 64 位 WCF 服务中。问题是 NBIS.Net 项目是一个 C++ 32 位项目,它不能在 IIS7 中工作。 如果我将项目更改为 6
本文整理了Java中gov.nist.javax.sdp.fields.ZoneField类的一些代码示例,展示了ZoneField类的具体用法。这些代码示例主要来源于Github/Stackover
Azure 应用服务中有没有办法证明 Azure 中的时间与 NIST 时间同步 http://www.time.gov/ ?在其他服务器环境中,我相信这是通过命令行完成的,该命令行显示服务器地址设置
我有一个大小为 100 万的随机序列,为了使用 NIST test suite ,我将Windows txt格式存储的序列转换为BCD,显然文件的长度变成了400万。因此,我运行测试并将比特流设置为
Azure 应用服务中有没有办法证明 Azure 中的时间与 NIST 时间同步 http://www.time.gov/ ?在其他服务器环境中,我相信这是通过命令行完成的,该命令行显示服务器地址设置
我用 Java 为 Android 客户端和服务器开发 Sip 应用程序,但是当我运行 Android 应用程序时。 我有错误 sipFactory.setPathName("gov.nist");
我正在尝试安全地生成随机数。它必须支持 NIST 标准,即 NIST SP 800-90A、SP 800-90B、SP 800-90C。我已经 read Java 9 有一个实现 SecureRand
所以,我正在编写一个语音识别程序。为此,我从 TIMIT 下载了 400MB 的数据。当我打算阅读 wav 文件时(我尝试了两个库),如下所示: import scipy.io.wavfile as
我正在开发一个基于 JAIN SIP 和 NIST 实现的 Java 应用程序,并且想要启用/查看 SIP 堆栈调试。 我找不到实现这一目标的可行方法 - 任何帮助将不胜感激。 谢谢!乔 最佳答案 初
我一定是做错了什么,但我看不出是什么。 我正在尝试让 VERIFY 命令显示剩余的尝试次数。 (我也曾尝试输入 PIN,但当我什么都做不了时就切回了这里。)这是我一直在尝试的代码片段: for (un
本文整理了Java中gov.nist.javax.sdp.fields.ZoneField.()方法的一些代码示例,展示了ZoneField.()的具体用法。这些代码示例主要来源于Github/Sta
我需要生成这样的公钥并对字节进行额外的签名(这将包括之前生成的 key ) 我需要构造字节:ASN.1 前缀 + 签名(33 字节压缩 NIST P-256 公钥) 签名应该从其他定义的私钥传递 EC
我写了一个 c 代码,它接受键的输入值,消息调用 openssl hmac 函数并生成 mac 代码的结果。输入值是从 NIST 测试 vector 中收集的 #define KEY_SIZE 11
我编写了一个调用 OpenSSL SHA1 生成摘要的 C 代码,但我生成的摘要不匹配。 #define MSG_SIZE 190 #include #include #include void
我正在尝试访问 NIST 网站上的表格: http://physics.nist.gov/PhysRefData/XrayMassCoef/tab3.html 假设我单击元素锌。我想使用 python
我们可能需要对我们软件中的一些数据进行加密以满足医疗保健隐私 (“HIPAA”) 规则,这些规则只是遵循 NIST公会线。但目前还不清楚哪些(如果有的话)加密库符合 NIST 标准。 是否有 NIST
各位程序员好!我想让我的软件用户能够以最方便、通用和平台独立的方式将信息从他们的 Windows Phone 设备安全地传输到几个不同的服务。最好使用 Microsoft 已经提供的工具。为此,我查看
我是一名优秀的程序员,十分优秀!