I'm looking to do something similar in my project. Where did you end up putting the broadcastPerspectiveMessage code? I was going to put it in my Project Library but realized system.perspective isn't available in the project library.
Functions in project libraries use the scope in which they are called, so if you call a function from a perspective scope, then system.perspective.* functions will be available. In fact if you read through @bmusson's posts you will see that he does have this function in a Project Library shared.util
However, if for some reason, you don't have access to the system.perspective.sendMessage() function, then messages sent with the proper scope and parameters with system.util.sendMessage() will also be "heard" from perspective. It's a little more involved to use, but can be made to work.