|
@ -44,7 +44,7 @@ var messagingConnector = function(response) { |
|
|
var channels = vAPI.messaging.channels; |
|
|
var channels = vAPI.messaging.channels; |
|
|
var channel, listener; |
|
|
var channel, listener; |
|
|
|
|
|
|
|
|
if ( response.broadcast === true && !response.portName ) { |
|
|
|
|
|
|
|
|
if ( response.broadcast === true && !response.channelName ) { |
|
|
for ( channel in channels ) { |
|
|
for ( channel in channels ) { |
|
|
if ( channels.hasOwnProperty(channel) === false ) { |
|
|
if ( channels.hasOwnProperty(channel) === false ) { |
|
|
continue; |
|
|
continue; |
|
@ -64,7 +64,7 @@ var messagingConnector = function(response) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( !listener ) { |
|
|
if ( !listener ) { |
|
|
channel = channels[response.portName]; |
|
|
|
|
|
|
|
|
channel = channels[response.channelName]; |
|
|
listener = channel && channel.listener; |
|
|
listener = channel && channel.listener; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -124,7 +124,7 @@ vAPI.messaging = { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.channels[channelName] = { |
|
|
this.channels[channelName] = { |
|
|
portName: channelName, |
|
|
|
|
|
|
|
|
channelName: channelName, |
|
|
listener: typeof callback === 'function' ? callback : null, |
|
|
listener: typeof callback === 'function' ? callback : null, |
|
|
send: function(message, callback) { |
|
|
send: function(message, callback) { |
|
|
if ( !vAPI.messaging.connector ) { |
|
|
if ( !vAPI.messaging.connector ) { |
|
@ -132,7 +132,7 @@ vAPI.messaging = { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
message = { |
|
|
message = { |
|
|
portName: vAPI.messaging.connectorId + '|' + this.portName, |
|
|
|
|
|
|
|
|
channelName: vAPI.messaging.connectorId + '|' + this.channelName, |
|
|
msg: message |
|
|
msg: message |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -144,7 +144,7 @@ vAPI.messaging = { |
|
|
sendAsyncMessage('ublock:background', message); |
|
|
sendAsyncMessage('ublock:background', message); |
|
|
}, |
|
|
}, |
|
|
close: function() { |
|
|
close: function() { |
|
|
delete vAPI.messaging.channels[this.portName]; |
|
|
|
|
|
|
|
|
delete vAPI.messaging.channels[this.channelName]; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|