如何使用星号在浏览器上生成sip地址



我需要在浏览器上生成一个动态sip地址,这样我的星号服务器就可以对同一sip地址进行调用。这样,我的网络浏览器将成为一个sip客户端,可以接收呼叫。

我可以看到webrtc是一种方式,但我不知道如何在浏览器上生成sip地址?

感谢

您需要像在任何其他情况下一样在星号中创建sip用户,并通过WebRTC向其注册,但首先必须在配置中启用它。听说你有我用来开始的教程。

若要创建动态sip用户,必须在星号中实时使用,那个么您的配置将从数据库中读取。如何从实时开始的有用链接:https://wiki.asterisk.org/wiki/display/AST/Realtime+数据库+配置https://wiki.asterisk.org/wiki/display/AST/SIP+实时,+MySQL+表+结构

您可以查看我在Asterisk 12+Realtime+WebRTC上的帖子:带有星号11 的Websocket连接失败

最重要的是,添加一个WebService,将一个peer插入到表sipeers中。该Web服务将由您的系统调用,以创建可立即使用SIP或其他方式(通过WS-WSS的SIP、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();
?>

相关内容

  • 没有找到相关文章