websockets: add support for user specified onmessage
This commit is contained in:
parent
c11a01d67c
commit
e68e7dd01d
|
@ -338,13 +338,13 @@ function($rootScope,
|
||||||
return '(' + id + ') ' + message;
|
return '(' + id + ') ' + message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ngWebsockets.connect(url,
|
ngWebsockets.connect(url,
|
||||||
protocol,
|
protocol,
|
||||||
{
|
{
|
||||||
'binaryType': "arraybuffer",
|
'binaryType': "arraybuffer",
|
||||||
'onopen': onopen,
|
'onopen': onopen,
|
||||||
'onclose': onclose,
|
'onclose': onclose,
|
||||||
'onmessage': onmessage,
|
|
||||||
'onerror': onerror,
|
'onerror': onerror,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,6 @@ function($rootScope, $q) {
|
||||||
}
|
}
|
||||||
$rootScope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type);
|
$rootScope.commands.push("RECV: " + evt.data + " TYPE:" + evt.type);
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var connect = function(url,
|
var connect = function(url,
|
||||||
|
@ -121,7 +120,14 @@ function($rootScope, $q) {
|
||||||
ws[property] = properties[property];
|
ws[property] = properties[property];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('onmessage' in properties) {
|
||||||
|
ws.onmessage = function(event) {
|
||||||
|
properties['onmessage'](event);
|
||||||
|
onmessage(event);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
ws.onmessage = onmessage;
|
ws.onmessage = onmessage;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var disconnect = function() {
|
var disconnect = function() {
|
||||||
|
|
Loading…
Reference in New Issue