Skip to content

Commit 941f355

Browse files
author
Igor Khomenko
committed
Merge pull request #88 from QuickBlox/develop.webrtc.QBWEBSDK-200
QBWEBSDK-200
2 parents 982fbc4 + b70e46d commit 941f355

File tree

1 file changed

+186
-65
lines changed

1 file changed

+186
-65
lines changed

samples/webrtc/config.js

Lines changed: 186 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,43 @@
1-
var QBApp = {
2-
appId: 28287,
3-
authKey: 'XydaWcf8OO9xhGT',
4-
authSecret: 'JZfqTspCvELAmnW'
5-
};
1+
;(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');
612

7-
var CONFIG = {
8-
debug: true,
9-
webrtc: {
10-
answerTimeInterval: 30,
11-
dialingTimeInterval: 5,
12-
disconnectTimeInterval: 30
13-
}
14-
};
15-
16-
var USE_DEV_USERS = true;
17-
18-
// dev users
19-
//
20-
if(USE_DEV_USERS){
13+
var CONFIG = {
14+
debug: true,
15+
webrtc: {
16+
answerTimeInterval: 30,
17+
dialingTimeInterval: 5,
18+
disconnectTimeInterval: 30
19+
}
20+
};
2121

22-
var QBUsers = [
23-
{
24-
id: 6970356,
25-
login: 'dev_user_1',
26-
password: 'dev_user_1',
27-
full_name: 'User 1',
28-
colour: 'ffaa00'
22+
/**
23+
* QBAppDefault for qa and dev
24+
* QBAppProd for production
25+
*/
26+
var QBAppProd = {
27+
appId: 92,
28+
authKey: 'wJHdOcQSxXQGWx5',
29+
authSecret: 'BTFsj7Rtt27DAmT'
2930
},
30-
{
31-
id: 6970368,
32-
login: 'dev_user_2',
33-
password: 'dev_user_2',
34-
full_name: 'User 2',
35-
colour: '0890ff'
36-
},
37-
{
38-
id: 6970375,
39-
login: 'dev_user_3',
40-
password: 'dev_user_3',
41-
full_name: 'User 3',
42-
colour: 'ff03a6'
43-
},
44-
{
45-
id: 6970379,
46-
login: 'dev_user_4',
47-
password: 'dev_user_4',
48-
full_name: 'User 4',
49-
colour: '60e27a'
50-
}
51-
];
31+
QBAppDefault = {
32+
appId: 28287,
33+
authKey: 'XydaWcf8OO9xhGT',
34+
authSecret: 'JZfqTspCvELAmnW'
35+
};
5236

53-
// prod users
54-
//
55-
}else{
56-
var QBUsers = [
37+
/** set QBApp */
38+
var QBApp = usersQuery === 'prod' ? QBAppProd : QBAppDefault;
39+
40+
var QBUsersQA = [
5741
{
5842
id: 5395743,
5943
login: 'webuser111',
@@ -96,18 +80,155 @@ var QBUsers = [
9680
full_name: 'User 6',
9781
colour: '01e209'
9882
}
83+
],
84+
QBUsersDev = [
85+
{
86+
id: 6970356,
87+
login: 'dev_user_1',
88+
password: 'dev_user_1',
89+
full_name: 'User 1',
90+
colour: 'ffaa00'
91+
},
92+
{
93+
id: 6970368,
94+
login: 'dev_user_2',
95+
password: 'dev_user_2',
96+
full_name: 'User 2',
97+
colour: '0890ff'
98+
},
99+
{
100+
id: 6970375,
101+
login: 'dev_user_3',
102+
password: 'dev_user_3',
103+
full_name: 'User 3',
104+
colour: 'ff03a6'
105+
},
106+
{
107+
id: 6970379,
108+
login: 'dev_user_4',
109+
password: 'dev_user_4',
110+
full_name: 'User 4',
111+
colour: '60e27a'
112+
}
113+
],
114+
QBUsersProd = [
115+
{
116+
id: 2436251,
117+
login: 'webrtc_user1',
118+
password: 'x6Bt0VDy5',
119+
full_name: 'User 1',
120+
colour: 'FD8209'
121+
},
122+
{
123+
id: 2436254,
124+
login: 'webrtc_user2',
125+
password: 'x6Bt0VDy5',
126+
full_name: 'User 2',
127+
colour: '1765FB'
128+
},
129+
{
130+
id: 2436257,
131+
login: 'webrtc_user3',
132+
password: 'x6Bt0VDy5',
133+
full_name: 'User 3',
134+
colour: 'F81480'
135+
},
136+
{
137+
id: 2436258,
138+
login: 'webrtc_user4',
139+
password: 'x6Bt0VDy5',
140+
full_name: 'User 4',
141+
colour: '39A345'
142+
},
143+
{
144+
id: 2436259,
145+
login: 'webrtc_user5',
146+
password: 'x6Bt0VDy5',
147+
full_name: 'User 5',
148+
colour: '921392'
149+
},
150+
{
151+
id: 2436262,
152+
login: 'webrtc_user6',
153+
password: 'x6Bt0VDy5',
154+
full_name: 'User 6',
155+
colour: '6594C5'
156+
},
157+
{
158+
id: 2436263,
159+
login: 'webrtc_user7',
160+
password: 'x6Bt0VDy5',
161+
full_name: 'User 7',
162+
colour: 'C1061E'
163+
},
164+
{
165+
id: 2436265,
166+
login: 'webrtc_user8',
167+
password: 'x6Bt0VDy5',
168+
full_name: 'User 8',
169+
colour: '898989'
170+
},
171+
{
172+
id: 2436266,
173+
login: 'webrtc_user9',
174+
password: 'x6Bt0VDy5',
175+
full_name: 'User 9',
176+
colour: 'C7B325'
177+
},
178+
{
179+
id: 2436269,
180+
login: 'webrtc_user10',
181+
password: 'x6Bt0VDy5',
182+
full_name: 'User 10',
183+
colour: 'BDA0CA'
184+
}
99185
];
100-
}
101186

102-
var MESSAGES = {
103-
'login': 'Login as any user on this computer and another user on another computer.',
104-
'create_session': 'Creating a session...',
105-
'connect': 'Connecting...',
106-
'connect_error': 'Something wrong with connect to chat. Check internet connection or user info and trying again.',
107-
'login_as': 'Logged in as ',
108-
'title_login': 'Choose a user to login with:',
109-
'title_callee': 'Choose users to call:',
110-
'calling': 'Calling...',
111-
'webrtc_not_avaible': 'WebRTC is not available in your browser',
112-
'no_internet': 'Please check your Internet connection and try again'
113-
};
187+
/** set QBUsers */
188+
var QBUsers = usersQuery === 'prod' ? QBUsersProd : usersQuery === 'dev' ? QBUsersDev : QBUsersQA;
189+
190+
var MESSAGES = {
191+
'login': 'Login as any user on this computer and another user on another computer.',
192+
'create_session': 'Creating a session...',
193+
'connect': 'Connecting...',
194+
'connect_error': 'Something wrong with connect to chat. Check internet connection or user info and trying again.',
195+
'login_as': 'Logged in as ',
196+
'title_login': 'Choose a user to login with:',
197+
'title_callee': 'Choose users to call:',
198+
'calling': 'Calling...',
199+
'webrtc_not_avaible': 'WebRTC is not available in your browser',
200+
'no_internet': 'Please check your Internet connection and try again'
201+
};
202+
203+
/**
204+
* PRIVATE
205+
*/
206+
/**
207+
* [_getQueryVar get value of key from search string of url]
208+
* @param {[string]} q [name of query]
209+
* @return {[string]} [value of query]
210+
*/
211+
function _getQueryVar(q) {
212+
var query = window.location.search.substring(1),
213+
vars = query.split("&"),
214+
answ = false;
215+
216+
vars.forEach(function(el, i){
217+
var pair = el.split('=');
218+
219+
if(pair[0] === q) {
220+
answ = pair[1];
221+
}
222+
});
223+
224+
return answ;
225+
}
226+
227+
/**
228+
* set configuration variables in global
229+
*/
230+
window.QBApp = QBApp;
231+
window.CONFIG = CONFIG;
232+
window.QBUsers = QBUsers;
233+
window.MESSAGES = MESSAGES;
234+
}(window));

0 commit comments

Comments
 (0)