# Broadcaster

## Overview

The `Broadcaster` object facilitates real-time communication and message broadcasting to clients connected to the same channel, offering methods for message sending, channel management, and listener identification.

## Functionality

Broadcasters can send messages to all other listeners on their channel using the `broadcastMessage(message)` method. The object also allows retrieval of the channel's name via `getChannelName()` and the broadcaster's nickname using `getName()`. To clean up resources or stop listening, the `destroy()` method unregisters the broadcaster from the channel.

## Methods Summarized

| Type                                                     | Name                                                   | Summary                                                                                |
| -------------------------------------------------------- | ------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| void                                                     | [broadcastMessage(message)](#broadcastmessage-message) | Sends a message to the all other listeners of the channel of this broadcaster.         |
| void                                                     | [destroy()](#destroy)                                  | Destroyes and unregister the listener for this channel.                                |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [getChannelName()](#getchannelname)                    | get the channel name where this broadcaster listens and sends messages to.             |
| [String](/reference/servoycore/dev-api/js-lib/string.md) | [getName()](#getname)                                  | Get the (nick) name for this broadcaster that will be send to other channel listeners. |

## Methods Detailed

### broadcastMessage(message)

Sends a message to the all other listeners of the channel of this broadcaster.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **message** The message to send to the other users of this channel

**Returns:** void

### destroy()

Destroyes and unregister the listener for this channel.

**Returns:** void

### getChannelName()

get the channel name where this broadcaster listens and sends messages to.

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) The channel name where this broadcaster listens and sends messages to.

### getName()

Get the (nick) name for this broadcaster that will be send to other channel listeners.

**Returns:** [String](/reference/servoycore/dev-api/js-lib/string.md) The (nick) name for this broadcaster that will be sent to other channel listeners

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoyextensions/server-plugins/clientmanager/broadcaster.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
