Skip to content

Commit f3f16d1

Browse files
author
Jan Maselj
committed
callbacks added
1 parent e7cddc2 commit f3f16d1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wsClient.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
function onOpen(event) {
134134
$log.debug('wsClient connected to [' + options.url + ']');
135135
$log.debug(event);
136+
if (options.callbacks.onOpen) {
137+
options.callbacks.onOpen();
138+
}
136139

137140
// no need for reconnecting
138141
if (reconnectInterval) {
@@ -153,6 +156,9 @@
153156
function onClose(event) {
154157
$log.debug('wsClient connection to [' + options.url + '] closed');
155158
$log.debug(event);
159+
if (options.callbacks.onClose) {
160+
options.callbacks.onClose();
161+
}
156162

157163
// no need for this if disconnected
158164
if (keepAliveInterval) {
@@ -181,6 +187,9 @@
181187
function onError(event) {
182188
$log.debug('wsClient connection to [' + options.url + '] error');
183189
$log.error(event);
190+
if (options.callbacks.onError) {
191+
options.callbacks.onError();
192+
}
184193
}
185194
};
186195
}

0 commit comments

Comments
 (0)