Unverified Commit f3fa2a7a authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Bug 40046: Support arbitrary watch events

parent 0197c6fe
......@@ -645,7 +645,6 @@ let event = {};
// data.
event.parsers = {
"stream" : info.streamStatusParser,
"status_client" : (data) => data,
// Currently unused:
// "circ" : info.circuitStatusParser,
};
......@@ -655,7 +654,7 @@ event.parsers = {
// we only extract streams that look like `"650" SP...`
event.messageToData = function (type, message) {
let dataText = message.match(/^650 \S+?\s(.*)/m)[1];
return dataText ? event.parsers[type.toLowerCase()](dataText) : null;
return (dataText && type.toLowerCase() in event.parsers) ? event.parsers[type.toLowerCase()](dataText) : null;
};
// __event.watchEvent(controlSocket, type, filter, onData)__.
......@@ -668,7 +667,7 @@ event.watchEvent = function (controlSocket, type, filter, onData, raw=false) {
function (message) {
let data = event.messageToData(type, message);
if (filter === null || filter(data)) {
if (raw) {
if (raw || !data) {
return onData(message);
}
onData(data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment