[英]What kinds Java APIs can I use to build a simple voice communications program?
I want to build a voice chat program for a group of friends, as several of them were hit by viruses that we believe to have been sent from an unknown user for Skype. 我想为一群朋友建立一个语音聊天程序,因为其中一些被我们认为是由未知用户为Skype发送的病毒所感染。 Skype also has other security problems where users can gain access to a user on their friends lists's IP, allowing for DDoS's and other such things.
Skype还存在其他安全问题,用户可以在其朋友列表的IP上访问该用户,从而允许进行DDoS和其他此类操作。 To help stop this, I want to build a simple voice chat program that I can host on my computer (or from a separate server, if it ever comes to that).
为了阻止这种情况,我想构建一个简单的语音聊天程序,该程序可以在我的计算机上托管(或从单独的服务器托管)。 I've heard that Java's built in APIs work for this, but which APIs should I specifically use, and what are some good sources/tutorials/videos to learn these?
我听说Java的内置API可以做到这一点,但是我应该专门使用哪些API,可以从哪些好的资源/教程/视频中学习呢?
Twilio will most likely fit your requirement. Twilio很可能会满足您的要求。 You can get started here: Twilio Quick Start .
您可以从这里开始: Twilio快速入门 。
It allows you to initiate and receive calls, even SMS. 它允许您发起和接听电话,甚至短信。 You will need to learn a bit of TwiML , but it's relatively simple.
您将需要学习一些TwiML ,但这是相对简单的。
The site has good sample code on common use cases. 该站点提供了有关常见用例的良好示例代码。 Here's a sample Java program that sends SMS messages .
这是一个发送SMS消息的示例Java程序。
Here's one that initiates an outgoing call - excerpt from the Twilio site: 这是一个发起拨出电话的电话 -来自Twilio网站的摘录:
import java.util.Map;
import java.util.HashMap;
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.instance.Call;
import com.twilio.sdk.resource.factory.CallFactory;
public class MakeCall {
public static final String ACCOUNT_SID = "AC123";
public static final String AUTH_TOKEN = "456bef";
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
Account mainAccount = client.getAccount();
CallFactory callFactory = mainAccount.getCallFactory();
Map<String, String> callParams = new HashMap<String, String>();
callParams.put("To", "5105551212"); // Replace with your phone number
callParams.put("From", "(510) 555-1212"); // Replace with a Twilio number
callParams.put("Url", "http://demo.twilio.com/welcome/voice/");
// Make the call
Call call = callFactory.create(callParams);
// Print the call SID (a 32 digit hex like CA123..)
System.out.println(call.getSid());
}
}
Important Note: Twilio has a free trial , but it will eventually involve some cost. 重要说明: Twilio有免费试用版 ,但最终会涉及一些费用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.