我需要在浏览器上生成动态sip地址,以便我的星号服务器可以在同一个SIP地址上发出呼叫。 这样我的网络浏览器就会变成一个可以接听电话的SIP客户端。
我可以看到webrtc的方式,但我不知道如何在浏览器上生成SIP地址?
由于
答案 0 :(得分:2)
您需要像任何其他情况一样在星号中创建sip用户并通过WebRTC注册,但首先必须在配置中启用它。听说你有tutorial that I use to start。
如果您想要创建动态sip用户,则必须在星号中使用实时,然后将从数据库中读取您的配置。有用的链接如何从实时开始:https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration https://wiki.asterisk.org/wiki/display/AST/SIP+Realtime,+MySQL+table+structure
答案 1 :(得分:1)
您可以在Asterisk 12 + Realtime + WebRTC上查看我的帖子:Websocket connection fails with asterisk 11
最重要的是,添加一个WebService以将对等体插入表格sippeers。您的系统将调用此Web服务,以使用SIP或其他任何方式创建即时可用于注册的对等方(SIP over WS / WSS,WebRTC ...)
如果您正在使用Unix并且需要.Net WebService,您可以使用NUSOAP和类似的东西:(sudo nano / var / html / www / mywebservice.php`。这是我使用的基本实现用于测试。
<?php
require_once("nusoap.php");
$namespace = "http://yourdomain.com";
// create a new soap server
$server = new soap_server();
// configure your WSDL
$server->configureWSDL("AsteriskRealtime");
// set your namespace
$server->wsdl->schemaTargetNamespace = $namespace;
// register your WebMethod
$server->register(
// method name:
'HelloWorld',
// parameter list:
array('name'=>'xsd:string'),
// return value(s):
array('return'=>'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'A simple hello world');
$server->wsdl->addComplexType(
'AsteriskExtensions',
'complexType',
'struct',
'all','',
array(
'name' => array('name' => 'name', 'type' => 'xsd:string'),
'custom_id' => array('name' => 'custom_id', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'AsteriskExtensionsArray',
'complexType',
'array','',
'SOAP-ENC:Array',array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:AsteriskExtensions[]')
),
'tns:AsteriskExtensions'
);
$server->register(
// method name:
'GetRegisteredExtensions',
// parameter list:
array(),
// return value(s):
array('AsteriskExtensions' => 'tns:AsteriskExtensionsArray'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'List the extensions registered in AsteriskRealtime database.');
$server->register(
// method name:
'AddUpdateExtension',
// parameter list:
array('name' => 'xsd:string', 'password' => 'xsd:string', 'custom_id' => 'xsd:string'),
// return value(s):
array('return' => 'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Add or Update an extension in AsteriskRealtime database. NAME is the PRIMARY KEY. Returns OK for success or ERR for failure.');
$server->register(
// method name:
'DeleteExtension',
// parameter list:
array('name' => 'xsd:string'),
// return value(s):
array('return' => 'xsd:string'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Delete an extension registered in AsteriskRealtime database. Returns OK for success or ERR for failure. ');
$server->register(
// method name:
'GetByCustomId',
// parameter list:
array('name' => 'xsd:string'),
// return value(s):
array('AsteriskExtensions' => 'tns:AsteriskExtensionsArray'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Gets an extension or a list of extensions for a CustomID. ');
function HelloWorld($sName)
{
return 'Hello ' . $sName . '! Hello world!';
}
function GetRegisteredExtensions()
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$result = array();
$req="SELECT * FROM `sippeers`";
$res=odbc_exec($conn,$req);
while($obj=odbc_fetch_object($res)) {
$result[] = array( 'name' => $obj->name, 'custom_id' => $obj->custom_id);
}
return $result;
}
function AddUpdateExtension($name,$password,$custom_id)
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$req="DELETE FROM `sippeers` WHERE `name` = '" . $name . "'";
$res=odbc_exec($conn,$req);
$req="insert into `sippeers` (`name`, `ipaddr`, `port`, `regseconds`, `defaultuser`, `fullcontact`, `regserver`, `useragent`, `lastms`, `host`, `type`, `context`, `permit`, `deny`, `secret`, `md5secret`, `remotesecret`, `transport`, `dtmfmode`, `directmedia`, `nat`, `callgroup`, `pickupgroup`, `language`, `disallow`, `allow`, `insecure`, `trustrpid`, `progressinband`, `promiscredir`, `useclientcode`, `accountcode`, `setvar`, `callerid`, `amaflags`, `callcounter`, `busylevel`, `allowoverlap`, `allowsubscribe`, `videosupport`, `maxcallbitrate`, `rfc2833compensate`, `mailbox`, `session-timers`, `session-expires`, `session-minse`, `session-refresher`, `t38pt_usertpsource`, `regexten`, `fromdomain`, `fromuser`, `qualify`, `defaultip`, `rtptimeout`, `rtpholdtimeout`, `sendrpid`, `outboundproxy`, `callbackextension`, `timert1`, `timerb`, `qualifyfreq`, `constantssrc`, `contactpermit`, `contactdeny`, `usereqphone`, `textsupport`, `faxdetect`, `buggymwi`, `auth`, `fullname`, `trunkname`, `cid_number`, `callingpres`, `mohinterpret`, `mohsuggest`, `parkinglot`, `hasvoicemail`, `subscribemwi`, `vmexten`, `autoframing`, `rtpkeepalive`, `call-limit`, `g726nonstandard`, `ignoresdpversion`, `allowtransfer`, `dynamic`, `path`, `supportpath`, `avpf`, `encryption`, `dtlsenable`, `dtlsverify`, `dtlscertfile`, `dtlsprivatekey`, `dtlssetup`, `force_avp`, `custom_id`) values('" . $name . "',NULL,NULL,NULL,'" . $name . "','','',NULL,'0','dynamic','friend','default',NULL,NULL,'" . $password . "',NULL,NULL,'udp,ws,wss','auto','no',NULL,NULL,NULL,NULL,NULL,'ulaw,alaw,g729,h264,g719,opus,vp8,gsm',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'no',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'yes','',NULL,'yes','yes','yes','no','/etc/asterisk/keys/asterisk.pem','/etc/asterisk/keys/asterisk.pem','actpass','yes','" . $custom_id . "')";
$res=odbc_exec($conn,$req);
return 'OK';
}
function DeleteExtension($name)
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$req="DELETE FROM `sippeers` WHERE `name` = '" . $name . "'";
$res=odbc_exec($conn,$req);
return 'OK';
}
function GetByCustomId($name)
{
$conn=odbc_connect('your-asterisk-connector-as-in-odbcinst.ini','your-mysql-user','your-mysql-password');
$result = array();
$req="SELECT * FROM `sippeers` WHERE `custom_id` = '" . $name . "'";
$res=odbc_exec($conn,$req);
while($obj=odbc_fetch_object($res)) {
$result[] = array( 'name' => $obj->name, 'custom_id' => $obj->custom_id);
}
return $result;
}
// Get our posted data if the service is being consumed
// otherwise leave this data blank.
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
// pass our posted data (or nothing) to the soap service
$server->service($POST_DATA);
exit();
?>