@qikdev/sdk 0.1.170 → 0.1.180
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1 -1
- package/package.json +4 -13
- package/src/api/qik.access.js +715 -750
- package/src/api/qik.api.js +3 -3
- package/src/api/qik.auth.js +797 -740
- package/src/api/qik.content.js +731 -712
- package/src/api/qik.core.js +1 -0
- package/src/api/qik.files.js +4 -40
- package/src/api/qik.socket.js +293 -305
- package/src/api/qik.utils.js +1 -3
- package/src/version.js +1 -1
- package/.husky/pre-commit +0 -5
- package/dist/sdk.js +0 -2
- package/dist/sdk.js.LICENSE.txt +0 -8
- package/eslint.config.js +0 -6
- package/yarn-error.log +0 -3598
package/src/api/qik.socket.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventDispatcher } from
|
|
1
|
+
import { EventDispatcher } from './qik.utils.js';
|
|
2
2
|
|
|
3
3
|
///////////////////////////////////////////////////
|
|
4
4
|
|
|
@@ -11,350 +11,338 @@ import { EventDispatcher } from "./qik.utils.js";
|
|
|
11
11
|
* @param {QikAPI} qik A reference to the parent instance of the QikCore module. This module is usually created by a QikCore instance that passes itself in as the first argument.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const QikSocket = function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// If the user isn't online
|
|
72
|
-
if (!service.connected) {
|
|
73
|
-
// Connect them now
|
|
74
|
-
await service.connect();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Subscribe to this key
|
|
78
|
-
service.subscribe(key);
|
|
79
|
-
|
|
80
|
-
// Listen for all relevant events
|
|
81
|
-
service.addEventListener(key, dispatchMessage);
|
|
82
|
-
|
|
83
|
-
function dispatchMessage(message) {
|
|
84
|
-
bucket.dispatch("message", message);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Destroy the service
|
|
88
|
-
bucket.destroy = function () {
|
|
14
|
+
const QikSocket = function(qik, mode) {
|
|
15
|
+
|
|
16
|
+
mode = mode || 'production';
|
|
17
|
+
|
|
18
|
+
if (!qik.auth) {
|
|
19
|
+
throw new Error(`Can't Instantiate QikSocket before QikAuth exists`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const windowID = qik.utils.guid();
|
|
24
|
+
|
|
25
|
+
///////////////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
let service = {
|
|
28
|
+
debug: false,
|
|
29
|
+
url: `wss://iqtm6zjz3l.execute-api.ap-southeast-2.amazonaws.com/${mode}`,
|
|
30
|
+
connected: false,
|
|
31
|
+
windowID,
|
|
32
|
+
autoreconnect:true,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let socket;
|
|
36
|
+
let timer;
|
|
37
|
+
let buckets = {};
|
|
38
|
+
const channels = {};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
//Create a new dispatcher
|
|
43
|
+
const dispatcher = new EventDispatcher();
|
|
44
|
+
dispatcher.bootstrap(service);
|
|
45
|
+
|
|
46
|
+
///////////////////////////////////////////////////
|
|
47
|
+
|
|
48
|
+
function getSubscriptions() {
|
|
49
|
+
return Object.keys(buckets);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
///////////////////////////////////////////////////
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @description Create an event dispatcher instance and subscribe to a new socket channel.
|
|
57
|
+
* This can then be used to receive socket events for this channel
|
|
58
|
+
* @alias socket.channel
|
|
59
|
+
* @param {String} key The key or name of the channel to subscribe to
|
|
60
|
+
* @example
|
|
61
|
+
* const socketChannel = await sdk.socket.channel('awesome:notifications')
|
|
62
|
+
* socketChannel.addEventListener('message', function(message) {
|
|
63
|
+
* console.log('Received a new message from the socket')
|
|
64
|
+
* })
|
|
65
|
+
*
|
|
66
|
+
* // Disconnect from this channel and remove all listeners
|
|
67
|
+
* socketChannel.destroy();
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
service.channel = async function(key) {
|
|
89
71
|
if (buckets[key]) {
|
|
90
|
-
|
|
91
|
-
service.unsubscribe(key);
|
|
92
|
-
buckets[key] = null;
|
|
72
|
+
return buckets[key];
|
|
93
73
|
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
74
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
75
|
+
const bucket = new EventDispatcher();
|
|
76
|
+
buckets[key] = bucket;
|
|
77
|
+
|
|
78
|
+
if (!service.connected) {
|
|
79
|
+
// Return the socket
|
|
80
|
+
await service.connect();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Subscribe to this channel
|
|
84
|
+
service.subscribe(key);
|
|
85
|
+
|
|
86
|
+
// Listen for all relevant events
|
|
87
|
+
service.addEventListener(key, dispatchMessage);
|
|
100
88
|
|
|
101
|
-
|
|
89
|
+
function dispatchMessage(message) {
|
|
90
|
+
bucket.dispatch('message', message);
|
|
91
|
+
}
|
|
102
92
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
// Destroy the service
|
|
94
|
+
bucket.destroy = function() {
|
|
95
|
+
service.removeAllListeners();
|
|
96
|
+
buckets[key] = null;
|
|
97
|
+
}
|
|
108
98
|
|
|
109
|
-
|
|
110
|
-
if (timer) {
|
|
111
|
-
return;
|
|
99
|
+
return buckets[key];
|
|
112
100
|
}
|
|
113
|
-
timer = setInterval(ping, 10000);
|
|
114
|
-
}
|
|
115
101
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
///////////////////////////////////////////////////
|
|
103
|
+
|
|
104
|
+
function ping() {
|
|
105
|
+
broadcast({
|
|
106
|
+
action: 'ping',
|
|
107
|
+
})
|
|
119
108
|
}
|
|
120
109
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
function socketOpened(event) {
|
|
128
|
-
service.debug ? console.log("[socket] Connection open", event) : null;
|
|
129
|
-
service.connected = true;
|
|
130
|
-
|
|
131
|
-
dispatcher.dispatch("connected", event);
|
|
132
|
-
|
|
133
|
-
// startHeartbeat();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function socketClosed(event) {
|
|
137
|
-
if (event.wasClean) {
|
|
138
|
-
service.debug
|
|
139
|
-
? console.log(
|
|
140
|
-
`[socket] Connection closed cleanly, code=${event.code} reason=${event.reason}`,
|
|
141
|
-
)
|
|
142
|
-
: null;
|
|
143
|
-
} else {
|
|
144
|
-
// e.g. server process killed or network down
|
|
145
|
-
// event.code is usually 1006 in this case
|
|
146
|
-
service.debug
|
|
147
|
-
? console.log("[socket] - connection closed due to error", event)
|
|
148
|
-
: null;
|
|
110
|
+
function startHeartbeat() {
|
|
111
|
+
if (timer) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
timer = setInterval(ping, 10000);
|
|
149
115
|
}
|
|
150
116
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
117
|
+
function stopHeartbeat() {
|
|
118
|
+
if (!timer) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
154
121
|
|
|
155
|
-
|
|
156
|
-
|
|
122
|
+
clearInterval(timer)
|
|
123
|
+
timer = null;
|
|
157
124
|
}
|
|
158
|
-
}
|
|
159
125
|
|
|
160
|
-
|
|
161
|
-
console.log("[event] socketError", event);
|
|
162
|
-
service.debug ? console.log("[socket] Error", error) : null;
|
|
163
|
-
dispatcher.dispatch("error", error);
|
|
164
|
-
}
|
|
126
|
+
///////////////////////////////////////////////////
|
|
165
127
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
128
|
+
function socketOpened(event) {
|
|
129
|
+
service.debug ? console.log("[socket] Connection open", event) : null;
|
|
130
|
+
service.connected = true;
|
|
169
131
|
|
|
170
|
-
|
|
171
|
-
dispatcher.dispatch("message", eventData);
|
|
132
|
+
dispatcher.dispatch('connected', event);
|
|
172
133
|
|
|
173
|
-
|
|
174
|
-
dispatcher.dispatch(eventData.channel, eventData);
|
|
134
|
+
// startHeartbeat();
|
|
175
135
|
}
|
|
176
|
-
}
|
|
177
136
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
137
|
+
async function socketClosed(event) {
|
|
138
|
+
if (event.wasClean) {
|
|
139
|
+
service.debug ? console.log(`[socket] Connection closed cleanly, code=${event.code} reason=${event.reason}`) : null;
|
|
140
|
+
} else {
|
|
141
|
+
// e.g. server process killed or network down
|
|
142
|
+
// event.code is usually 1006 in this case
|
|
143
|
+
service.debug ? console.log('[socket] - connection closed due to error', event) : null
|
|
144
|
+
}
|
|
181
145
|
|
|
182
|
-
|
|
146
|
+
service.connected = false;
|
|
147
|
+
dispatcher.dispatch('disconnected', event);
|
|
148
|
+
socket = null;
|
|
183
149
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
function check() {
|
|
187
|
-
if (service.connected) {
|
|
188
|
-
return resolve(socket);
|
|
150
|
+
if(service.autoreconnect) {
|
|
151
|
+
service.reconnect();
|
|
189
152
|
}
|
|
153
|
+
}
|
|
190
154
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
///////////////////////////////////////////////////
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @description Connect to the socket service
|
|
202
|
-
* @alias socket.connect
|
|
203
|
-
* @example
|
|
204
|
-
* const connected = await sdk.socket.connect()
|
|
205
|
-
*
|
|
206
|
-
*/
|
|
207
|
-
service.connect = async function () {
|
|
208
|
-
if (socket) {
|
|
209
|
-
if (!socket.connected) {
|
|
210
|
-
return wait();
|
|
211
|
-
}
|
|
155
|
+
function socketError(error) {
|
|
156
|
+
console.log('[event] socketError', event);
|
|
157
|
+
service.debug ? console.log("[socket] Error", error) : null;
|
|
158
|
+
dispatcher.dispatch('error', error);
|
|
159
|
+
}
|
|
212
160
|
|
|
213
|
-
|
|
214
|
-
|
|
161
|
+
function socketMessageReceived(event) {
|
|
162
|
+
const eventData = JSON.parse(event.data);
|
|
163
|
+
service.debug ? console.log("[socket] message received", eventData) : null;
|
|
164
|
+
|
|
165
|
+
// Dispatch a generic message
|
|
166
|
+
dispatcher.dispatch('message', eventData);
|
|
167
|
+
|
|
168
|
+
if (eventData.channel) {
|
|
169
|
+
dispatcher.dispatch(eventData.channel, eventData);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function broadcast(data) {
|
|
174
|
+
socket.send(JSON.stringify(data));
|
|
215
175
|
}
|
|
216
176
|
|
|
217
|
-
|
|
177
|
+
///////////////////////////////////////////////////
|
|
178
|
+
|
|
179
|
+
function wait() {
|
|
180
|
+
return new Promise(function(resolve) {
|
|
181
|
+
function check() {
|
|
182
|
+
if (service.connected) {
|
|
183
|
+
return resolve(socket);
|
|
184
|
+
}
|
|
218
185
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
186
|
+
setTimeout(check, 1000);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
check();
|
|
190
|
+
})
|
|
224
191
|
}
|
|
225
192
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
193
|
+
///////////////////////////////////////////////////
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @description Connect to the socket service
|
|
197
|
+
* @alias socket.connect
|
|
198
|
+
* @example
|
|
199
|
+
* const connected = await sdk.socket.connect()
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
service.connect = async function() {
|
|
203
|
+
if (socket) {
|
|
204
|
+
|
|
205
|
+
if (!socket.connected) {
|
|
206
|
+
return wait();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
console.log('[socket] - Socket is already connected');
|
|
210
|
+
return socket;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const accessToken = qik.auth.getCurrentToken();
|
|
214
|
+
|
|
215
|
+
if (!accessToken) {
|
|
216
|
+
service.debug ? console.log('[socket] - Must be authenticated to connect to socket') : null;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
socket = new WebSocket(`${service.url}?access_token=${accessToken}&windowid=${windowID}`);
|
|
221
|
+
socket.addEventListener('close', socketClosed);
|
|
222
|
+
socket.addEventListener('error', socketError);
|
|
223
|
+
socket.addEventListener('open', socketOpened);
|
|
224
|
+
socket.addEventListener('message', socketMessageReceived);
|
|
225
|
+
service.debug ? console.log('[socket] - Connected with event listeners') : null;
|
|
226
|
+
|
|
227
|
+
return wait();
|
|
250
228
|
}
|
|
251
229
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
console.log("[socket] - Socket is not connected");
|
|
278
|
-
return;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @description Reconnect to the socket service
|
|
233
|
+
* @alias socket.reconnect
|
|
234
|
+
* @example
|
|
235
|
+
* const connected = await sdk.socket.reconnect()
|
|
236
|
+
*
|
|
237
|
+
*/
|
|
238
|
+
service.reconnect = async function() {
|
|
239
|
+
if(service.connected) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
service.debug ? console.log(`[socket] reconnecting...`) : null;
|
|
244
|
+
|
|
245
|
+
// Reconnect all listeners
|
|
246
|
+
const result = await service.connect();
|
|
247
|
+
|
|
248
|
+
// Resubscribe to all previously connected channels
|
|
249
|
+
const subscribedChannels = Object.keys(channels);
|
|
250
|
+
subscribedChannels.forEach(function(channel) {
|
|
251
|
+
service.subscribe(channel);
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
return result;
|
|
279
255
|
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
///////////////////////////////////////////////////
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @description Close the connection to the socket service
|
|
262
|
+
* @alias socket.close
|
|
263
|
+
* @example
|
|
264
|
+
* const closed = await sdk.socket.close()
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
267
|
+
service.close = async function() {
|
|
268
|
+
if (!socket) {
|
|
269
|
+
console.log('[socket] - Socket is not connected');
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
280
272
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
service.disconnect = service.close;
|
|
294
|
-
|
|
295
|
-
///////////////////////////////////////////////////
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* @description Subscribe to a socket channel
|
|
299
|
-
* @alias socket.subscribe
|
|
300
|
-
* @param {String} key The name of the channel to subscribe to
|
|
301
|
-
* @example
|
|
302
|
-
* const subscribed = await sdk.socket.subscribe('some:cool:alert')
|
|
303
|
-
*
|
|
304
|
-
*/
|
|
305
|
-
service.subscribe = async function (channel) {
|
|
306
|
-
if (!socket) {
|
|
307
|
-
console.log(
|
|
308
|
-
`[socket] - Can't subscribe to channel as socket is not connected`,
|
|
309
|
-
);
|
|
310
|
-
return;
|
|
273
|
+
const previousSetting = service.autoreconnect;
|
|
274
|
+
service.autoreconnect = false;
|
|
275
|
+
socket.close();
|
|
276
|
+
socket.removeEventListener('close', socketClosed);
|
|
277
|
+
socket.removeEventListener('error', socketError);
|
|
278
|
+
socket.removeEventListener('open', socketOpened);
|
|
279
|
+
socket.removeEventListener('message', socketMessageReceived);
|
|
280
|
+
socket = null;
|
|
281
|
+
socketClosed({ wasClean: true });
|
|
282
|
+
service.autoreconnect = previousSetting;
|
|
311
283
|
}
|
|
312
284
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
285
|
+
service.disconnect = service.close;
|
|
286
|
+
|
|
287
|
+
///////////////////////////////////////////////////
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @description Subscribe to a socket channel
|
|
291
|
+
* @alias socket.subscribe
|
|
292
|
+
* @param {String} key The name of the channel to subscribe to
|
|
293
|
+
* @example
|
|
294
|
+
* const subscribed = await sdk.socket.subscribe('some:cool:alert')
|
|
295
|
+
*
|
|
296
|
+
*/
|
|
297
|
+
service.subscribe = async function(channel) {
|
|
298
|
+
if (!socket) {
|
|
299
|
+
console.log(`[socket] - Can't subscribe to channel as socket is not connected`);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
broadcast({
|
|
304
|
+
action: 'subscribe',
|
|
305
|
+
channel,
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
channels[channel] = true;
|
|
309
|
+
|
|
310
|
+
dispatcher.dispatch('subscribe', channel)
|
|
311
|
+
service.debug ? console.log(`[socket] - subscribed to ${channel}`) : null;
|
|
340
312
|
}
|
|
341
313
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
314
|
+
///////////////////////////////////////////////////
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @description Unsubscribe from a socket channel
|
|
318
|
+
* @alias socket.unsubscribe
|
|
319
|
+
* @param {String} key The name of the channel to unsubscribe from
|
|
320
|
+
* @example
|
|
321
|
+
* const unsubscribed = await sdk.socket.unsubscribe('some:cool:alert')
|
|
322
|
+
*
|
|
323
|
+
*/
|
|
324
|
+
service.unsubscribe = async function(channel) {
|
|
325
|
+
if (!socket) {
|
|
326
|
+
console.log(`[socket] - Can't unsubscribe from channel as socket is not connected`);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
broadcast({
|
|
331
|
+
action: 'unsubscribe',
|
|
332
|
+
channel,
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
delete channels[channel];
|
|
336
|
+
|
|
337
|
+
dispatcher.dispatch('unsubscribe', channel)
|
|
338
|
+
service.debug ? console.log(`[socket] - unsubscribed from ${channel}`) : null;
|
|
339
|
+
}
|
|
346
340
|
|
|
347
|
-
|
|
341
|
+
///////////////////////////////////////////////////
|
|
348
342
|
|
|
349
|
-
|
|
350
|
-
service.debug
|
|
351
|
-
? console.log(`[socket] - unsubscribed from ${channel}`)
|
|
352
|
-
: null;
|
|
353
|
-
};
|
|
343
|
+
return service;
|
|
354
344
|
|
|
355
|
-
|
|
345
|
+
}
|
|
356
346
|
|
|
357
|
-
return service;
|
|
358
|
-
};
|
|
359
347
|
|
|
360
|
-
export default QikSocket;
|
|
348
|
+
export default QikSocket;
|
package/src/api/qik.utils.js
CHANGED
|
@@ -702,14 +702,12 @@ service.mapParameters = function(parameters) {
|
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
704
|
|
|
705
|
-
|
|
706
|
-
|
|
707
705
|
if (Array.isArray(value)) {
|
|
708
706
|
value.forEach(function(v) {
|
|
709
707
|
array.push(`${key}=${encodeURIComponent(v)}`);
|
|
710
708
|
})
|
|
711
709
|
} else {
|
|
712
|
-
array.push(encodeURIComponent(key) + '=' + encodeURIComponent(
|
|
710
|
+
array.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
|
|
713
711
|
}
|
|
714
712
|
|
|
715
713
|
})
|