@lazyapps/change-notifier-socket-io 0.1.0 → 0.1.1
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/notifier.js +4 -1
- package/package.json +1 -1
package/notifier.js
CHANGED
|
@@ -32,7 +32,7 @@ export const initSockets = (correlationConfig, io, ioAuthHandler) => {
|
|
|
32
32
|
ioLog.debug(`Communication error with ${socket.id}: ${error}`);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
socket.on('register', (resolvers) => {
|
|
35
|
+
socket.on('register', (resolvers, ack) => {
|
|
36
36
|
try {
|
|
37
37
|
if (!ioAuthHandler(socket.decoded_token, resolvers)) {
|
|
38
38
|
ioLog.error(
|
|
@@ -40,6 +40,7 @@ export const initSockets = (correlationConfig, io, ioAuthHandler) => {
|
|
|
40
40
|
socket.decoded_token
|
|
41
41
|
})`,
|
|
42
42
|
);
|
|
43
|
+
if (typeof ack === 'function') ack({ error: 'unauthorized' });
|
|
43
44
|
socket.disconnect();
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
@@ -49,12 +50,14 @@ export const initSockets = (correlationConfig, io, ioAuthHandler) => {
|
|
|
49
50
|
),
|
|
50
51
|
);
|
|
51
52
|
ioLog.debug(`Registered ${socket.id} for ${JSON.stringify(resolvers)}`);
|
|
53
|
+
if (typeof ack === 'function') ack();
|
|
52
54
|
} catch (err) {
|
|
53
55
|
ioLog.error(
|
|
54
56
|
`Can't register ${socket.id} for ${JSON.stringify(
|
|
55
57
|
resolvers,
|
|
56
58
|
)}: ${err}`,
|
|
57
59
|
);
|
|
60
|
+
if (typeof ack === 'function') ack({ error: String(err) });
|
|
58
61
|
}
|
|
59
62
|
});
|
|
60
63
|
});
|