# How to send message to a target by broadcastMessage

**URL:** <https://forum.heroiclabs.com/t/how-to-send-message-to-a-target-by-broadcastmessage/6232>\
**Category:** Runtime Framework\
**Tags:** server-framework, typescript\
**Created:** [May 27, 2025, 8:30am UTC](https://forum.heroiclabs.com/t/how-to-send-message-to-a-target-by-broadcastmessage/6232 "2025-05-27T08:30:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrbug](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@mrbug](https://forum.heroiclabs.com/u/mrbug)\
**Post date:** [May 27, 2025, 8:30am UTC](https://forum.heroiclabs.com/t/how-to-send-message-to-a-target-by-broadcastmessage/6232/1 "2025-05-27T08:30:47Z")

</div>

Hi. in relayed matches players can send targeted messages to others. how do this in authoritative match?

`dispatcher.broadcastMessage(message.opCode, Targets, message.sender, true);`

**what is the best practice to determinate sender targets?**

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [May 27, 2025, 10:26am UTC](https://forum.heroiclabs.com/t/how-to-send-message-to-a-target-by-broadcastmessage/6232/2 "2025-05-27T10:26:48Z")

</div>

Hello @mrbug,

There’s a few examples of how to use `broadcastMessage` in our [project-template](https://github.com/heroiclabs/nakama-project-template/blob/master/match_handler.ts).

If you set the value to `null` then the message is broadcast to all the players connected to the match.

If you need to target specific subsets of players that will depend on your message handling server logic.

Best.

---

<div class="post-metadata">

**Author:** ![mrbug](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@mrbug](https://forum.heroiclabs.com/u/mrbug)\
**Post date:** [May 27, 2025, 11:02am UTC](https://forum.heroiclabs.com/t/how-to-send-message-to-a-target-by-broadcastmessage/6232/3 "2025-05-27T11:02:05Z")

</div>

> [@sesposito](#):
>
> If you need to target specific subsets of players that will depend on your message handling server logic.

ty for respond!  
in template there is no targeted broadcast! and i don’t know how to get the targets list when using  
SendMatchStateAsync function in unity c# code.  
how relayed match code works on server?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [May 27, 2025, 11:24am UTC](https://forum.heroiclabs.com/t/how-to-send-message-to-a-target-by-broadcastmessage/6232/4 "2025-05-27T11:24:48Z")

</div>

In some places in the template it’s omitted, which effectively defaults to nil (broadcast to all).

In an authoritative multiplayer game you send some data to the server based on the protocol you’ve defined, and it’s up to the match loop implementation to target specific player or broadcast to all depending match state and received message.
