From ec0efcb9f9fd212da9f974b5d802184f937fd27e Mon Sep 17 00:00:00 2001
From: "lilong@dgg.net" <123456789>
Date: Wed, 17 Mar 2021 15:33:30 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=89=93=E7=94=B5=E8=AF=9D?=
=?UTF-8?q?=E6=9C=8D=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
resources/views/layout.blade.php | 142 +++++++++++++++++--------------
1 file changed, 76 insertions(+), 66 deletions(-)
diff --git a/resources/views/layout.blade.php b/resources/views/layout.blade.php
index 84085ab5..4c75e58d 100644
--- a/resources/views/layout.blade.php
+++ b/resources/views/layout.blade.php
@@ -35,10 +35,8 @@
- -
-
- 呼叫状态:未呼叫
-
+
-
+
-
@@ -218,81 +216,93 @@
content: '/change_my_password_form'
})
})
+
+
var userAgentSession;
- var userAgent = new SIP.UA({
- uri: '1001@192.168.254.216',
- wsServers: ['wss://testcall.shupian.cn:7443'],
- authorizationUser: '1001',
- password: '1234',
- displayName: '1001',
- hackIpInContact: true,
- rtcpMuxPolicy: 'negotiate',
- hackWssInTransport: true,
- rel100: SIP.C.supported.SUPPORTED,
- log: {
- level: 0, //日志等级
- },
- /**
- * sip.js生成的随机contact字符串 设置后会以此为后缀 可以搭配 cusContactName使用,根据自身业务进行使用
- * 设置前: sofia/internal/sip:admin10@df7jal23ls0d.invalid;
- * 设置后: sofia/internal/sip:admin10@192.168.0.253;
- *
- *
- hackIpInContact: "106.13.223.129",
- userAgentString: "myAwesomeApp",
- registerOptions: {
+ var userAgent;
+ function initUserAgent(){
+ userAgent = new SIP.UA({
+ uri: '1001@192.168.254.216',
+ wsServers: ['wss://testcall.shupian.cn:7443'],
+ authorizationUser: '1001',
+ password: '1234',
+ displayName: '1001',
+ hackIpInContact: true,
+ rtcpMuxPolicy: 'negotiate',
+ hackWssInTransport: true,
+ rel100: SIP.C.supported.SUPPORTED,
+ log: {
+ level: 0, //日志等级
+ },
+ /**
+ * sip.js生成的随机contact字符串 设置后会以此为后缀 可以搭配 cusContactName使用,根据自身业务进行使用
+ * 设置前: sofia/internal/sip:admin10@df7jal23ls0d.invalid;
+ * 设置后: sofia/internal/sip:admin10@192.168.0.253;
+ *
+ *
+ hackIpInContact: "106.13.223.129",
+ userAgentString: "myAwesomeApp",
+ registerOptions: {
expires: 300,
registrar: 'sip:xdwh.dgg.net',
},
- **
- * 此处是笔者自定义的参数,因为注册到fs时,sip.js会随机生成contact字符串,如:sofia/internal/sip:admin10@df7jal23ls0d.invalid;
- * 笔者自己添加了一个参数,对sip.js的源码进行了修改 ,修改后效果 sofia/internal/sip:1012@192.168.0.253 不需要的可以不理会此参数
- * 此处纠正问题,官方提供了一个参数[contactName],使用此参数即可,sip.js使用官方的即可
- * contactName:"1012"
- */
- contactName:"1001"
- });
- //注册成功
- userAgent.on('registered', function (e) {
- $('#sip-status').text($("#regBtn").text());
- });
- //未注册成功
- userAgent.on('unregistered', function () {
- $('#sip-status').text($("#unregBtn").text());
- });
- //监听来电
- userAgent.on('invite', function (session) {
- userAgentSession = session;
- userAgentSession.on('bye', function (request) {//挂机
- $('#call-status').html('已结束');
+ **
+ * 此处是笔者自定义的参数,因为注册到fs时,sip.js会随机生成contact字符串,如:sofia/internal/sip:admin10@df7jal23ls0d.invalid;
+ * 笔者自己添加了一个参数,对sip.js的源码进行了修改 ,修改后效果 sofia/internal/sip:1012@192.168.0.253 不需要的可以不理会此参数
+ * 此处纠正问题,官方提供了一个参数[contactName],使用此参数即可,sip.js使用官方的即可
+ * contactName:"1012"
+ */
+ contactName:"1001"
});
- userAgentSession.on('terminated', function (message, cause) {//结束
- $('#call-status').html('呼叫结束');
+ //注册成功
+ userAgent.on('registered', function (e) {
+ $('#sip-status').text($("#regBtn").text());
});
- userAgentSession.accept({
- media: {
- render: {
- remote: document.getElementById('remoteVideo'),
- local: document.getElementById('localVideo')
- },
- constraints: {
- audio: true,
- video: false
+ //未注册成功
+ userAgent.on('unregistered', function () {
+ $('#sip-status').text($("#unregBtn").text());
+ $('#sip-status').click(function () {
+ return;
+ })
+ });
+ //监听来电
+ userAgent.on('invite', function (session) {
+ userAgentSession = session;
+ userAgentSession.on('terminated', function (message, cause) {//结束
+ $("#call-status").html("")
+ layer.msg("通话结束");
+ });
+ userAgentSession.accept({
+ media: {
+ render: {
+ remote: document.getElementById('remoteVideo'),
+ local: document.getElementById('localVideo')
+ },
+ constraints: {
+ audio: true,
+ video: false
+ }
}
- }
+ });
+ $("#call-status").html('挂断')
+ $("#call-status span").click(function () {
+ if(userAgent){
+ userAgentSession.terminate()
+ }
+ })
});
- });
- //监听是否接了电话
- userAgent.on('accepted', function (data) {
- $('#state3').text('accepted:' + data);
- });
- userAgent.start()
+ userAgent.start()
+ }
+
$("#regBtn").click(function () {
+ initUserAgent();
userAgent.register();
})
$("#unregBtn").click(function () {
- userAgent.unregister()
+ if(userAgent){
+ userAgent.unregister()
+ }
})
});