# 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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [getChannelName()](#getchannelname)                    | get the channel name where this broadcaster listens and sends messages to.             |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) 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](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) The (nick) name for this broadcaster that will be sent to other channel listeners

***
