Table of Contents

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

See also on MDN

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

name string

Remarks

-BroadcastChannel, the interface it belongs to.

See also on MDN

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.

See also on MDN

Onmessage

[Value("onmessage")]
public EventHandlerNonNull Onmessage { get; set; }

Property Value

EventHandlerNonNull

Onmessageerror

[Value("onmessageerror")]
public EventHandlerNonNull Onmessageerror { get; set; }

Property Value

EventHandlerNonNull

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

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

-BroadcastChannel, the interface it belongs to.

See also on MDN

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

message dynamic

Returns

GlobalObject.Undefined

None.

Remarks

-BroadcastChannel, the interface it belongs to.

See also on MDN