BroadcastChannel Class
A channel of messages between the windows and the workers of the same origin (https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts). The messages are delivered to the channels with the same name of the browsing context group of the global object (the windows of the top-level browsing context and of its nested browsing contexts, and their workers), through their event loops.
public sealed class BroadcastChannel : EventTargetRemarks
The relevant global object of a channel is the current global object when it is created (e.g. the window or the worker of the script that creates it); a channel created without current global object neither sends nor receives messages. The messages are serialized by the script engine of the global object (structured clone); without script engine, only the .NET primitive values and the serializable platform objects can be sent.
See also
- Inheritance
EventTargetBroadcastChannel
Constructors
| Name | Description |
|---|---|
| BroadcastChannel(string) | https://html.spec.whatwg.org/multipage/web-messaging.html#dom-broadcastchannel |
BroadcastChannel(string)
BroadcastChannel.csProperties
| Name | Description |
|---|---|
| Name | Gets the channel name. |
| OnMessage | Gets or sets the event handler of the message event. |
| OnMessageError | Gets or sets the event handler of the messageerror event. |
Gets the channel name.
public string Name { get; }OnMessage
BroadcastChannel.csGets or sets the event handler of the message event.
OnMessageError
BroadcastChannel.csGets or sets the event handler of the messageerror event.
Methods
| Name | Description |
|---|---|
| Close() | Closes the channel: it no longer sends nor receives messages (https://html.spec.whatwg.org/multipage/web-messaging.html#dom-broadcastchannel-close). |
| PostMessage(object?) | Sends a message to the other channels with the same name of the windows and the workers of the same origin (https://html.spec.whatwg.org/multipage/web-messaging.html#dom-broadcastchannel-postmessage). |
Close()
BroadcastChannel.csCloses the channel: it no longer sends nor receives messages (https://html.spec.whatwg.org/multipage/web-messaging.html#dom-broadcastchannel-close).
public void Close()PostMessage(object?)
BroadcastChannel.csSends a message to the other channels with the same name of the windows and the workers of the same origin (https://html.spec.whatwg.org/multipage/web-messaging.html#dom-broadcastchannel-postmessage).
Parameters
messageobject?- The message: a value of the script engine, a .NET primitive value or a serializable platform object, or null for
undefined.