|
|
@@ -11,6 +11,7 @@
|
|
11
|
11
|
maxHeight: 360
|
|
12
|
12
|
}
|
|
13
|
13
|
};
|
|
|
14
|
+
|
|
14
|
15
|
URL = window.URL || window.webkitURL;
|
|
15
|
16
|
|
|
16
|
17
|
var localStream = null;
|
|
|
@@ -38,25 +39,32 @@
|
|
38
|
39
|
|
|
39
|
40
|
//注册成功
|
|
40
|
41
|
userAgent.on('registered', function(data) {
|
|
|
42
|
+ $(".tooltip_text").text("初始化成功...");
|
|
|
43
|
+ //setTimeout(function(){$(".tooltip_text").text("分机号:"+$.cookie("extno")"); }, 3000);
|
|
41
|
44
|
console.info("registered: ", data.response.status_code, ",", data.response.reason_phrase);
|
|
42
|
45
|
});
|
|
43
|
46
|
|
|
44
|
47
|
//注册失败
|
|
45
|
48
|
userAgent.on('registrationFailed', function(data) {
|
|
|
49
|
+ $(".tooltip_text").text("注册失败...")
|
|
46
|
50
|
console.log("registrationFailed, ", data);
|
|
47
|
51
|
//console.warn("registrationFailed, ", data.response.status_code, ",", data.response.reason_phrase, " cause - ", data.cause);
|
|
48
|
52
|
});
|
|
49
|
53
|
|
|
50
|
54
|
//注册超时
|
|
51
|
55
|
userAgent.on('registrationExpiring', function() {
|
|
|
56
|
+ $(".tooltip_text").text("注册超时...")
|
|
52
|
57
|
console.warn("registrationExpiring");
|
|
53
|
58
|
});
|
|
54
|
59
|
|
|
55
|
60
|
userAgent.on('newRTCSession', function(data) {
|
|
56
|
61
|
console.info('onNewRTCSession: ', data);
|
|
57
|
|
-
|
|
|
62
|
+
|
|
58
|
63
|
//通话呼入
|
|
59
|
64
|
if(data.originator == 'remote') {
|
|
|
65
|
+ if(data.request.data.split("Extension ")[1]){
|
|
|
66
|
+ var stringHr_1=data.request.data.split("Extension ")[1].split('"')[0]
|
|
|
67
|
+ }
|
|
60
|
68
|
console.info("incomingSession, answer the call----------------------");
|
|
61
|
69
|
incomingSession = data.session;
|
|
62
|
70
|
data.session.answer({
|
|
|
@@ -84,15 +92,23 @@
|
|
84
|
92
|
if(data.originator == 'remote' && currentSession == null) {
|
|
85
|
93
|
currentSession = incomingSession;
|
|
86
|
94
|
incomingSession = null;
|
|
87
|
|
- console.info("setCurrentSession - ", currentSession);
|
|
|
95
|
+ //layer.msg("setCurrentSession - ", currentSession);
|
|
88
|
96
|
}
|
|
89
|
97
|
});
|
|
90
|
98
|
data.session.on('confirmed', function(data) {
|
|
|
99
|
+ $(".tooltip_text").text("通话中...") //呼入建立
|
|
|
100
|
+ if(stringHr_1){
|
|
|
101
|
+ var p = '<a href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?Number=' + stringHr_1+'">来电弹屏<i class="fa fa-times-circle"></i></a>';
|
|
|
102
|
+ $(".J_menuTab").removeClass("active");
|
|
|
103
|
+ var nif = '<iframe class="J_iframe J_iframeNew" name="iframe" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + stringHr_1+'"></iframe>';
|
|
|
104
|
+ $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
|
|
|
105
|
+ $(".J_menuTabs .page-tabs-content").append(p);
|
|
|
106
|
+ }
|
|
91
|
107
|
console.info('onConfirmed - ', data);
|
|
92
|
108
|
if(data.originator == 'remote' && currentSession == null) {
|
|
93
|
109
|
currentSession = incomingSession;
|
|
94
|
110
|
incomingSession = null;
|
|
95
|
|
- console.info("setCurrentSession - ", currentSession);
|
|
|
111
|
+ //layer.msg("setCurrentSession - ", currentSession);
|
|
96
|
112
|
}
|
|
97
|
113
|
});
|
|
98
|
114
|
data.session.on('sdp', function(data) {
|
|
|
@@ -100,16 +116,18 @@
|
|
100
|
116
|
});
|
|
101
|
117
|
|
|
102
|
118
|
data.session.on('progress', function(data) {
|
|
103
|
|
- console.info('onProgress - ', data.originator);
|
|
|
119
|
+ $(".tooltip_text").text("呼入振铃...")
|
|
|
120
|
+ //layer.msg('onProgress - ', data.originator);
|
|
104
|
121
|
if(data.originator == 'remote') {
|
|
105
|
|
- console.info('onProgress, response - ', data.response);
|
|
|
122
|
+ //layer.msg('onProgress, response - ', data.response);
|
|
106
|
123
|
}
|
|
107
|
124
|
});
|
|
108
|
125
|
data.session.on('peerconnection', function(data) {
|
|
109
|
|
- console.info('onPeerconnection - ', data.peerconnection);
|
|
|
126
|
+ $(".tooltip_text").text("呼叫建立...")//呼入建立
|
|
|
127
|
+ //layer.msg('onPeerconnection - ', data.peerconnection);
|
|
110
|
128
|
data.peerconnection.onaddstream = function(ev) {
|
|
111
|
|
- console.info('onaddstream from remote ----------- ', ev);
|
|
112
|
|
- // <!-- videoView.src = URL.createObjectURL(ev.stream); -->
|
|
|
129
|
+ //layer.msg('onaddstream from remote ----------- ', ev);
|
|
|
130
|
+ //<!-- videoView.src = URL.createObjectURL(ev.stream); -->
|
|
113
|
131
|
videoView.srcObject = ev.stream;
|
|
114
|
132
|
};
|
|
115
|
133
|
});
|
|
|
@@ -123,29 +141,30 @@
|
|
123
|
141
|
}
|
|
124
|
142
|
});
|
|
125
|
143
|
|
|
126
|
|
- console.info("call register");
|
|
|
144
|
+ //console.info("call register");
|
|
127
|
145
|
|
|
128
|
146
|
userAgent.start();
|
|
129
|
147
|
}
|
|
130
|
|
-
|
|
131
|
|
- // Register callbacks to desired call events
|
|
132
|
148
|
var eventHandlers = {
|
|
133
|
149
|
'progress': function(e) {
|
|
134
|
|
- console.log('call is in progress');
|
|
|
150
|
+ $(".tooltip_text").text("呼出振铃...");
|
|
135
|
151
|
},
|
|
136
|
152
|
'failed': function(e) {
|
|
137
|
|
- console.log('call failed: ', e);
|
|
|
153
|
+ $(".tooltip_text").text("呼叫失败...");
|
|
|
154
|
+ //layer.msg('呼叫失败', e);
|
|
138
|
155
|
},
|
|
139
|
156
|
'ended': function(e) {
|
|
140
|
|
- console.log('call ended : ', e);
|
|
|
157
|
+ $(".tooltip_text").text("通话结束...");
|
|
|
158
|
+ //layer.msg('呼叫结束', e); //对方挂机,通话结束
|
|
141
|
159
|
},
|
|
142
|
160
|
'confirmed': function(e) {
|
|
143
|
|
- console.log('call confirmed');
|
|
|
161
|
+ $(".tooltip_text").text("呼叫建立...");
|
|
|
162
|
+ //layer.msg('呼叫建立');
|
|
144
|
163
|
}
|
|
145
|
164
|
};
|
|
146
|
165
|
|
|
147
|
166
|
function testCall() {
|
|
148
|
|
- var sip_phone_number_ = document.getElementById("sip_phone_number").innerHTML.toString();
|
|
|
167
|
+ var sip_phone_number_ = document.getElementById("sip_phone_number").value.toString();
|
|
149
|
168
|
var options = {
|
|
150
|
169
|
'eventHandlers': eventHandlers,
|
|
151
|
170
|
'mediaConstraints': {
|
|
|
@@ -159,19 +178,31 @@
|
|
159
|
178
|
'mediaStream': localStream
|
|
160
|
179
|
};
|
|
161
|
180
|
outgoingSession = userAgent.call(sip_phone_number_, options);
|
|
|
181
|
+
|
|
|
182
|
+ var p = '<a style="background: #24c792; color: #FFFFFF;" href="javascript:;" class="active J_menuTab" data-id="./callScreen/callScreen.html?Number=' + sip_phone_number_+'">外呼弹屏<i class="fa fa-times-circle"></i></a>';
|
|
|
183
|
+ $(".J_menuTab").removeClass("active");
|
|
|
184
|
+ var nif = '<iframe class="J_iframe J_iframeNew" name="iframe" width="100%" height="100%" src="./callScreen/callScreen.html?Number=' + sip_phone_number_+'"></iframe>';
|
|
|
185
|
+ $(".J_mainContent").find("iframe.J_iframe").hide().parents(".J_mainContent").append(nif);
|
|
|
186
|
+ $(".J_menuTabs .page-tabs-content").append(p);
|
|
162
|
187
|
}
|
|
163
|
188
|
|
|
164
|
189
|
function reg() {
|
|
165
|
|
- console.log('register----------->');
|
|
|
190
|
+ $(".tooltip_text").text("注册...");
|
|
|
191
|
+ //console.log('register----------->');
|
|
166
|
192
|
userAgent.register();
|
|
167
|
193
|
}
|
|
168
|
194
|
|
|
169
|
195
|
function unReg() {
|
|
170
|
|
- console.log('unregister----------->');
|
|
|
196
|
+ $(".tooltip_text").text("注销...");
|
|
|
197
|
+ //console.log('unregister----------->');
|
|
171
|
198
|
userAgent.unregister(true);
|
|
172
|
199
|
}
|
|
173
|
200
|
|
|
174
|
201
|
function hangup() {
|
|
175
|
|
- console.log('hangup----------->');
|
|
|
202
|
+ debugger
|
|
|
203
|
+ //window.frames[1].clearInter();
|
|
|
204
|
+ $(".tooltip_text").text("挂断...");
|
|
|
205
|
+ //console.log('hangup----------->');
|
|
176
|
206
|
userAgent.terminateSessions();
|
|
177
|
|
- }
|
|
|
207
|
+ }
|
|
|
208
|
+
|