Snabel
Snabel3y ago

Monkey patch Broadcast Channel to send messages to current context

Essentially what I want to do is be able to connect to new BroadcastChannel("test_channel"); which I in the same context want to post messages to and still be able to recieve them. So if my pretty little drawing helps:
|---same javascript context----------|
| |-patched test_channel source----| |
| | Send messages here! | |
| |--------------------------------| |
| |
| |-test_channel-------------------| |
| | Recieve messages here | |
| |--------------------------------| |
| |
| |-test_channel-------------------| |
| | and here! | |
| |--------------------------------| |
|------------------------------------|
|---same javascript context----------|
| |-patched test_channel source----| |
| | Send messages here! | |
| |--------------------------------| |
| |
| |-test_channel-------------------| |
| | Recieve messages here | |
| |--------------------------------| |
| |
| |-test_channel-------------------| |
| | and here! | |
| |--------------------------------| |
|------------------------------------|
5 Replies
Andreu Botella (they/them)
I think you can do that just fine
Snabel
SnabelOP3y ago
Oh, I'm stupid, it certainly does work. I was sure that it didn't when I tried it before (although that was like a month ago). Thanks!
Andreu Botella (they/them)
it worked a month ago
Snabel
SnabelOP3y ago
hmm, was probably me doing something wrong then

Did you find this page helpful?