Class BroadcastChannel
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The BroadcastChannel interface represents a named channel that any {{glossary("browsing context")}} of a given {{glossary("origin")}} can subscribe to. It allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via a BroadcastChannelmessage event fired at all BroadcastChannel objects listening to the channel, except the object that sent the message.
[Value("BroadcastChannel")]
public class BroadcastChannel : EventTarget
- Inheritance
-
BroadcastChannel
- Inherited Members
Remarks
-Another, more heavyweight, way of communicating between browser contexts: ServiceWorker.
-Broadcast Channel API overview
Constructors
BroadcastChannel()
public BroadcastChannel()
BroadcastChannel(string)
The BroadcastChannel() constructor creates a new
BroadcastChannel and connects it to the underlying channel.
public BroadcastChannel(string name)
Parameters
namestring
Remarks
-BroadcastChannel, the interface it belongs to.
Properties
Name
The name read-only property of the BroadcastChannel interface returns a string, which uniquely identifies the given channel with its name. This name is passed to the BroadcastChannel.BroadCastChannel constructor at creation time and is therefore read-only.
[Value("name")]
public string Name { get; }
Property Value
- string
A string.
Remarks
-BroadcastChannel, the interface it belongs to.
Onmessage
[Value("onmessage")]
public EventHandlerNonNull Onmessage { get; set; }
Property Value
Onmessageerror
[Value("onmessageerror")]
public EventHandlerNonNull Onmessageerror { get; set; }
Property Value
Methods
Close()
The close() method of the BroadcastChannel interface terminates the connection to
the underlying channel, allowing the object to be garbage collected.
This is a necessary step to perform
as there is no other way for a browser to know
that this channel is not needed anymore.
[Value("close")]
public GlobalObject.Undefined Close()
Returns
Remarks
-BroadcastChannel, the interface it belongs to.
PostMessage(dynamic)
The postMessage() method of the BroadcastChannel interface sends a message,
which can be of any kind of Object,
to each listener in any browsing context with the same origin.
The message is transmitted as a BroadcastChannelmessage event
targeted at each BroadcastChannel bound to the channel.
[Value("postMessage")]
public GlobalObject.Undefined PostMessage(dynamic message)
Parameters
messagedynamic
Returns
- GlobalObject.Undefined
None.
Remarks
-BroadcastChannel, the interface it belongs to.