Skip to content

Commit 368af9a

Browse files
committed
Merge pull request #122 from QuickBlox/develop.QBWEBSDK-240
New logic for test users & switch a camera
2 parents 05465bb + 5577206 commit 368af9a

File tree

13 files changed

+1479
-1274
lines changed

13 files changed

+1479
-1274
lines changed

.jshintrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
"inject",
2323
"expect",
2424
"spyOn",
25-
25+
2626
"QB",
2727
"CONFIG",
2828
"QBApp",
29-
"QBUsers"
29+
"QBUsers",
30+
"Promise"
3031
]
31-
}
32+
}

js/modules/webrtc/qbWebRTCClient.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* - onStopCallListener(session, userID, extension)
1212
* - onUpdateCallListener(session, userID, extension)
1313
*/
14+
'use strict';
1415

1516
var WebRTCSession = require('./qbWebRTCSession');
1617
var WebRTCSignalingProcessor = require('./qbWebRTCSignalingProcessor');
@@ -41,6 +42,38 @@ function WebRTCClient(service, connection) {
4142
this.sessions = {};
4243
}
4344

45+
/**
46+
* [function description]
47+
* @param {[string]} spec [specify what type of devices you wnat to get.
48+
* Possible values: audioinput, audiooutput, videoinput]
49+
* @return {[array]} [array of devices]
50+
*/
51+
WebRTCClient.prototype.getMediaDevices = function(spec) {
52+
var specDevices = [],
53+
errMsg = 'Browser does not support output device selection.';
54+
55+
return new Promise(function(resolve, reject) {
56+
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
57+
reject(errMsg);
58+
Helpers.traceWarning(errMsg);
59+
} else {
60+
navigator.mediaDevices.enumerateDevices().then(function(devices) {
61+
if(spec) {
62+
devices.forEach(function(device, i) {
63+
if(device.kind === spec) {
64+
specDevices.push(device);
65+
}
66+
});
67+
68+
resolve(specDevices);
69+
} else {
70+
resolve(devices);
71+
}
72+
});
73+
}
74+
});
75+
};
76+
4477
/**
4578
* A map with all sessions the user had/have.
4679
* @type {Object.<string, Object>}

js/modules/webrtc/qbWebRTCHelpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ WebRTCHelpers.CallType = {
7676
AUDIO: 2
7777
};
7878

79-
module.exports = WebRTCHelpers;
79+
module.exports = WebRTCHelpers;

quickblox.min.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/webrtc/config.js

Lines changed: 34 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -1,235 +1,36 @@
11
;(function(window) {
2-
/**
3-
* Add parameter to url search
4-
* for switch users groups
5-
*
6-
* Possible options:
7-
* https://examples.com?users=prod
8-
* https://examples.com?users=dev
9-
* https://examples.com - for qa by default
10-
*/
11-
var usersQuery = _getQueryVar('users');
12-
13-
var CONFIG = {
14-
debug: true,
15-
webrtc: {
16-
answerTimeInterval: 30,
17-
dialingTimeInterval: 5,
18-
disconnectTimeInterval: 30,
19-
statsReportTimeInterval: 5
20-
}
21-
};
22-
23-
/**
24-
* QBAppDefault for qa and dev
25-
* QBAppProd for production
26-
*/
27-
var QBAppProd = {
28-
appId: 92,
29-
authKey: 'wJHdOcQSxXQGWx5',
30-
authSecret: 'BTFsj7Rtt27DAmT'
31-
},
32-
QBAppDefault = {
33-
appId: 28287,
34-
authKey: 'XydaWcf8OO9xhGT',
35-
authSecret: 'JZfqTspCvELAmnW'
36-
};
37-
38-
/** set QBApp */
39-
var QBApp = usersQuery === 'qa' ? QBAppDefault : usersQuery === 'dev' ? QBAppDefault : QBAppProd;
40-
41-
var QBUsersQA = [
42-
{
43-
id: 5395743,
44-
login: 'webuser111',
45-
password: 'webuser111',
46-
full_name: 'User 1',
47-
colour: 'FD8209'
48-
},
49-
{
50-
id: 5395747,
51-
login: 'webuser112',
52-
password: 'webuser112',
53-
full_name: 'User 2',
54-
colour: '11a209'
55-
},
56-
{
57-
id: 5681538,
58-
login: 'webuser113',
59-
password: 'webuser113',
60-
full_name: 'User 3',
61-
colour: '11a2a9'
62-
},
63-
{
64-
id: 5719859,
65-
login: 'webuser114',
66-
password: 'webuser114',
67-
full_name: 'User 4',
68-
colour: '51c209'
69-
},
70-
{
71-
id: 5719860,
72-
login: 'webuser115',
73-
password: 'webuser115',
74-
full_name: 'User 5',
75-
colour: '511209'
76-
},
77-
{
78-
id: 5719866,
79-
login: 'webuser116',
80-
password: 'webuser116',
81-
full_name: 'User 6',
82-
colour: '01e209'
83-
}
84-
],
85-
QBUsersDev = [
86-
{
87-
id: 6970356,
88-
login: 'dev_user_1',
89-
password: 'dev_user_1',
90-
full_name: 'User 1',
91-
colour: 'ffaa00'
92-
},
93-
{
94-
id: 6970368,
95-
login: 'dev_user_2',
96-
password: 'dev_user_2',
97-
full_name: 'User 2',
98-
colour: '0890ff'
99-
},
100-
{
101-
id: 6970375,
102-
login: 'dev_user_3',
103-
password: 'dev_user_3',
104-
full_name: 'User 3',
105-
colour: 'ff03a6'
106-
},
107-
{
108-
id: 6970379,
109-
login: 'dev_user_4',
110-
password: 'dev_user_4',
111-
full_name: 'User 4',
112-
colour: '60e27a'
113-
}
114-
],
115-
QBUsersProd = [
116-
{
117-
id: 2436251,
118-
login: 'webrtc_user1',
119-
password: 'x6Bt0VDy5',
120-
full_name: 'User 1',
121-
colour: 'FD8209'
122-
},
123-
{
124-
id: 2436254,
125-
login: 'webrtc_user2',
126-
password: 'x6Bt0VDy5',
127-
full_name: 'User 2',
128-
colour: '1765FB'
129-
},
130-
{
131-
id: 2436257,
132-
login: 'webrtc_user3',
133-
password: 'x6Bt0VDy5',
134-
full_name: 'User 3',
135-
colour: 'F81480'
136-
},
137-
{
138-
id: 2436258,
139-
login: 'webrtc_user4',
140-
password: 'x6Bt0VDy5',
141-
full_name: 'User 4',
142-
colour: '39A345'
143-
},
144-
{
145-
id: 2436259,
146-
login: 'webrtc_user5',
147-
password: 'x6Bt0VDy5',
148-
full_name: 'User 5',
149-
colour: '921392'
150-
},
151-
{
152-
id: 2436262,
153-
login: 'webrtc_user6',
154-
password: 'x6Bt0VDy5',
155-
full_name: 'User 6',
156-
colour: '6594C5'
157-
},
158-
{
159-
id: 2436263,
160-
login: 'webrtc_user7',
161-
password: 'x6Bt0VDy5',
162-
full_name: 'User 7',
163-
colour: 'C1061E'
164-
},
165-
{
166-
id: 2436265,
167-
login: 'webrtc_user8',
168-
password: 'x6Bt0VDy5',
169-
full_name: 'User 8',
170-
colour: '898989'
171-
},
172-
{
173-
id: 2436266,
174-
login: 'webrtc_user9',
175-
password: 'x6Bt0VDy5',
176-
full_name: 'User 9',
177-
colour: 'C7B325'
178-
},
179-
{
180-
id: 2436269,
181-
login: 'webrtc_user10',
182-
password: 'x6Bt0VDy5',
183-
full_name: 'User 10',
184-
colour: 'BDA0CA'
185-
}
186-
];
187-
188-
/** set QBUsers */
189-
var QBUsers = usersQuery === 'qa' ? QBUsersQA : usersQuery === 'dev' ? QBUsersDev : QBUsersProd;
190-
191-
var MESSAGES = {
192-
'login': 'Login as any user on this computer and another user on another computer.',
193-
'create_session': 'Creating a session...',
194-
'connect': 'Connecting...',
195-
'connect_error': 'Something wrong with connect to chat. Check internet connection or user info and trying again.',
196-
'login_as': 'Logged in as ',
197-
'title_login': 'Choose a user to login with:',
198-
'title_callee': 'Choose users to call:',
199-
'calling': 'Calling...',
200-
'webrtc_not_avaible': 'WebRTC is not available in your browser',
201-
'no_internet': 'Please check your Internet connection and try again'
202-
};
203-
204-
/**
205-
* PRIVATE
206-
*/
207-
/**
208-
* [_getQueryVar get value of key from search string of url]
209-
* @param {[string]} q [name of query]
210-
* @return {[string]} [value of query]
211-
*/
212-
function _getQueryVar(q) {
213-
var query = window.location.search.substring(1),
214-
vars = query.split("&"),
215-
answ = false;
216-
217-
vars.forEach(function(el, i){
218-
var pair = el.split('=');
219-
220-
if(pair[0] === q) {
221-
answ = pair[1];
222-
}
223-
});
224-
225-
return answ;
226-
}
227-
228-
/**
229-
* set configuration variables in global
230-
*/
231-
window.QBApp = QBApp;
232-
window.CONFIG = CONFIG;
233-
window.QBUsers = QBUsers;
234-
window.MESSAGES = MESSAGES;
2+
var CONFIG = {
3+
debug: true,
4+
webrtc: {
5+
answerTimeInterval: 30,
6+
dialingTimeInterval: 5,
7+
disconnectTimeInterval: 30,
8+
statsReportTimeInterval: 5
9+
}
10+
};
11+
12+
var CREDENTIALS = {
13+
appId: 92,
14+
authKey: 'wJHdOcQSxXQGWx5',
15+
authSecret: 'BTFsj7Rtt27DAmT'
16+
};
17+
18+
var MESSAGES = {
19+
'login': 'Login as any user on this computer and another user on another computer.',
20+
'create_session': 'Creating a session...',
21+
'connect': 'Connecting...',
22+
'connect_error': 'Something wrong with connect to chat. Check internet connection or user info and trying again.',
23+
'login_as': 'Logged in as ',
24+
'title_login': 'Choose a user to login with:',
25+
'title_callee': 'Choose users to call:',
26+
'calling': 'Calling...',
27+
'webrtc_not_avaible': 'WebRTC is not available in your browser',
28+
'no_internet': 'Please check your Internet connection and try again'
29+
};
30+
31+
window.CONFIG = {
32+
'CREDENTIALS': CREDENTIALS,
33+
'APP_CONFIG': CONFIG,
34+
'MESSAGES': MESSAGES
35+
};
23536
}(window));

samples/webrtc/images/user.svg

Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)