Я пытаюсь разработать SIP-приложение в Java-окружении с помощью Mizu JVoIP SDK.
Я загружаю del JVOIP.jar с сайта, помещаю его в библиотеку и связываю его.
Я пишу ниже исходный код как простое приложение с автоответчиком, но не получилось.
Я заметил, что мое приложение не прослушивает порт 5060!!!
Нет звонка мероприятие?!!!
Есть предложения?
import webphone.*;
/**
* MizuTech VoIP Application
* This application registers with a SIP server and automatically answers incoming calls
*
* Note: If you get compilation errors, run FindMizuPackage.java to see the exact
* class names in the webphone package, as they may differ slightly from what's used here.
*/
public class App {
private static webphone webphoneobj;
private static boolean isRegistered = false;
// SIP Configuration - Update these with your SIP server details
private static final String SIP_SERVER = "127.0.0.1";
private static final String USERNAME = "mtz5060";
private static final String PASSWORD = "password";
private static final int SIP_PORT = 5060;
public static void main(String[] args) throws Exception {
System.out.println("MizuTech VoIP Application - Starting...");
try {
// Initialize the WebPhone object
webphoneobj = new webphone();
// Set up notification listener for incoming calls
SIPNotificationListener sipNotificationListener= new IncomingCallListener();
webphoneobj.API_SetNotificationListener(sipNotificationListener);
// Configure SIP settings
configureSIP();
// Register with SIP server
registerWithSIP();
// Keep the application running
System.out.println("Application is running. Waiting for incoming calls...");
System.out.println("Press Ctrl+C to exit.");
// Keep the main thread alive
while (true) {
Thread.sleep(1000);
// Check registration status periodically
if (!isRegistered) {
System.out.println("Re-registering with SIP server...");
registerWithSIP();
}
}
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
}
}
/**
* Configure SIP server settings
*/
private static void configureSIP() {
try {
// Set SIP server address
webphoneobj.API_SetParameter("serveraddress", SIP_SERVER);
// Set SIP port
webphoneobj.API_SetParameter("serverport", String.valueOf(SIP_PORT));
// Set username
webphoneobj.API_SetParameter("username", USERNAME);
// Set password
webphoneobj.API_SetParameter("password", PASSWORD);
System.out.println("SIP configuration completed.");
System.out.println("Server: " + SIP_SERVER);
System.out.println("Username: " + USERNAME);
} catch (Exception e) {
System.err.println("Error configuring SIP: " + e.getMessage());
throw e;
}
}
/**
* Register with the SIP server
*/
private static void registerWithSIP() {
try {
System.out.println("Registering with SIP server...");
// Register with SIP server
boolean result = webphoneobj.API_Register();
if (result ) {
isRegistered = true;
System.out.println("Successfully registered with SIP server!");
} else {
isRegistered = false;
System.err.println("Failed to register with SIP server. Error code: " + result);
}
} catch (Exception e) {
isRegistered = false;
System.err.println("Error during registration: " + e.getMessage());
}
}
/**
* Listener class to handle incoming call notifications
*/
static class IncomingCallListener extends SIPNotificationListener {
@Override
public void onStatus(SIPNotification.Status e) {
try {
System.out.println(">>>>>>"+e.getStatusText());
// Check if this is an incoming call that is ringing
if (e.getStatus() == SIPNotification.Status.STATUS_CALL_RINGING &&
e.getEndpointType() == SIPNotification.Status.DIRECTION_IN) {
int line = e.getLine();
String callerId = e.getPeer();
String displayName = e.getPeerDisplayname();
String callId = e.getCallID();
System.out.println("\n=== INCOMING CALL DETECTED ===");
System.out.println("Line: " + line);
System.out.println("Caller ID: " + callerId);
System.out.println("Display Name: " + (displayName != null ? displayName : "Unknown"));
System.out.println("Call ID: " + callId);
// Get additional call details
try {
String callerDetails = webphoneobj.API_GetCallerID(line);
String incomingDisplay = webphoneobj.API_GetIncomingDisplay(line);
if (callerDetails != null && !callerDetails.isEmpty()) {
System.out.println("Caller Details: " + callerDetails);
}
if (incomingDisplay != null && !incomingDisplay.isEmpty()) {
System.out.println("Incoming Display: " + incomingDisplay);
}
} catch (Exception ex) {
// Ignore errors when getting additional details
}
// Answer the incoming call
System.out.println("Answering call...");
boolean acceptResult = webphoneobj.API_Accept(line);
if (acceptResult) {
System.out.println("Call answered successfully!");
System.out.println("Call is now active on line " + line);
} else {
System.err.println("Failed to answer call. Error code: " + acceptResult);
}
System.out.println("==============================\n");
}
// Handle call connected status
else if (e.getStatus() == SIPNotification.Status.STATUS_CALL_CONNECT) {
System.out.println("Call connected on line " + e.getLine());
}
// Handle call ended status
else if (e.getStatus() == SIPNotification.Status.STATUS_CALL_FINISHED) {
System.out.println("Call ended on line " + e.getLine());
}
// Handle registration status
else if (e.getStatus() == SIPNotification.Status.STATUS_REGISTERED) {
isRegistered = true;
System.out.println("Registration confirmed with SIP server.");
}
else if (e.getStatus() == SIPNotification.Status.STATUS_REGISTERFAILED) {
isRegistered = false;
System.err.println("Unregistered from SIP server.");
}
} catch (Exception ex) {
System.err.println("Error in notification listener: " + ex.getMessage());
ex.printStackTrace();
}
}
// @Override
// public void onMessage(SIPNotification.essage e) {
// // Handle SIP messages if needed
// System.out.println("SIP Message received: " + e.getMessage());
// }
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... h-mizu-sdk
Как реализовать приложение автоответчика для SIP с помощью Mizu sdk ⇐ JAVA
Программисты JAVA общаются здесь
-
Anonymous
1766924279
Anonymous
Я пытаюсь разработать SIP-приложение в Java-окружении с помощью Mizu JVoIP SDK.
Я загружаю del JVOIP.jar с сайта, помещаю его в библиотеку и связываю его.
Я пишу ниже исходный код как простое приложение с автоответчиком, но не получилось.
Я заметил, что мое приложение не прослушивает порт 5060!!!
Нет звонка мероприятие?!!!
Есть предложения?
import webphone.*;
/**
* MizuTech VoIP Application
* This application registers with a SIP server and automatically answers incoming calls
*
* Note: If you get compilation errors, run FindMizuPackage.java to see the exact
* class names in the webphone package, as they may differ slightly from what's used here.
*/
public class App {
private static webphone webphoneobj;
private static boolean isRegistered = false;
// SIP Configuration - Update these with your SIP server details
private static final String SIP_SERVER = "127.0.0.1";
private static final String USERNAME = "mtz5060";
private static final String PASSWORD = "password";
private static final int SIP_PORT = 5060;
public static void main(String[] args) throws Exception {
System.out.println("MizuTech VoIP Application - Starting...");
try {
// Initialize the WebPhone object
webphoneobj = new webphone();
// Set up notification listener for incoming calls
SIPNotificationListener sipNotificationListener= new IncomingCallListener();
webphoneobj.API_SetNotificationListener(sipNotificationListener);
// Configure SIP settings
configureSIP();
// Register with SIP server
registerWithSIP();
// Keep the application running
System.out.println("Application is running. Waiting for incoming calls...");
System.out.println("Press Ctrl+C to exit.");
// Keep the main thread alive
while (true) {
Thread.sleep(1000);
// Check registration status periodically
if (!isRegistered) {
System.out.println("Re-registering with SIP server...");
registerWithSIP();
}
}
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
}
}
/**
* Configure SIP server settings
*/
private static void configureSIP() {
try {
// Set SIP server address
webphoneobj.API_SetParameter("serveraddress", SIP_SERVER);
// Set SIP port
webphoneobj.API_SetParameter("serverport", String.valueOf(SIP_PORT));
// Set username
webphoneobj.API_SetParameter("username", USERNAME);
// Set password
webphoneobj.API_SetParameter("password", PASSWORD);
System.out.println("SIP configuration completed.");
System.out.println("Server: " + SIP_SERVER);
System.out.println("Username: " + USERNAME);
} catch (Exception e) {
System.err.println("Error configuring SIP: " + e.getMessage());
throw e;
}
}
/**
* Register with the SIP server
*/
private static void registerWithSIP() {
try {
System.out.println("Registering with SIP server...");
// Register with SIP server
boolean result = webphoneobj.API_Register();
if (result ) {
isRegistered = true;
System.out.println("Successfully registered with SIP server!");
} else {
isRegistered = false;
System.err.println("Failed to register with SIP server. Error code: " + result);
}
} catch (Exception e) {
isRegistered = false;
System.err.println("Error during registration: " + e.getMessage());
}
}
/**
* Listener class to handle incoming call notifications
*/
static class IncomingCallListener extends SIPNotificationListener {
@Override
public void onStatus(SIPNotification.Status e) {
try {
System.out.println(">>>>>>"+e.getStatusText());
// Check if this is an incoming call that is ringing
if (e.getStatus() == SIPNotification.Status.STATUS_CALL_RINGING &&
e.getEndpointType() == SIPNotification.Status.DIRECTION_IN) {
int line = e.getLine();
String callerId = e.getPeer();
String displayName = e.getPeerDisplayname();
String callId = e.getCallID();
System.out.println("\n=== INCOMING CALL DETECTED ===");
System.out.println("Line: " + line);
System.out.println("Caller ID: " + callerId);
System.out.println("Display Name: " + (displayName != null ? displayName : "Unknown"));
System.out.println("Call ID: " + callId);
// Get additional call details
try {
String callerDetails = webphoneobj.API_GetCallerID(line);
String incomingDisplay = webphoneobj.API_GetIncomingDisplay(line);
if (callerDetails != null && !callerDetails.isEmpty()) {
System.out.println("Caller Details: " + callerDetails);
}
if (incomingDisplay != null && !incomingDisplay.isEmpty()) {
System.out.println("Incoming Display: " + incomingDisplay);
}
} catch (Exception ex) {
// Ignore errors when getting additional details
}
// Answer the incoming call
System.out.println("Answering call...");
boolean acceptResult = webphoneobj.API_Accept(line);
if (acceptResult) {
System.out.println("Call answered successfully!");
System.out.println("Call is now active on line " + line);
} else {
System.err.println("Failed to answer call. Error code: " + acceptResult);
}
System.out.println("==============================\n");
}
// Handle call connected status
else if (e.getStatus() == SIPNotification.Status.STATUS_CALL_CONNECT) {
System.out.println("Call connected on line " + e.getLine());
}
// Handle call ended status
else if (e.getStatus() == SIPNotification.Status.STATUS_CALL_FINISHED) {
System.out.println("Call ended on line " + e.getLine());
}
// Handle registration status
else if (e.getStatus() == SIPNotification.Status.STATUS_REGISTERED) {
isRegistered = true;
System.out.println("Registration confirmed with SIP server.");
}
else if (e.getStatus() == SIPNotification.Status.STATUS_REGISTERFAILED) {
isRegistered = false;
System.err.println("Unregistered from SIP server.");
}
} catch (Exception ex) {
System.err.println("Error in notification listener: " + ex.getMessage());
ex.printStackTrace();
}
}
// @Override
// public void onMessage(SIPNotification.essage e) {
// // Handle SIP messages if needed
// System.out.println("SIP Message received: " + e.getMessage());
// }
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79856182/how-implement-auto-answer-aoo-for-sip-with-mizu-sdk[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия