# Match Runtime Reference

This page lists all functions exposed in the match handler Dispatcher type.

## Match runtime [#](/content/docs/nakama/server-framework/lua-runtime/function-reference/match-runtime/#Match%20runtime/index.html)

### broadcast_message [#](/content/docs/nakama/server-framework/lua-runtime/function-reference/match-runtime/#broadcast_message/index.html)

Send a message to one or more presences. This may be called at any point in the match loop to give match participants information about match state changes. May also be useful inside the match join callback to send initial state to the user on successful join. Note that when broadcasting to multiple presences, if any presence is invalid then the broadcast will not occur.

| Parameters |
| --- |
| Name | Default | Description |
| --- | --- | --- |
| op_code | number | REQUIRED | Numeric message op code. |
| data | string | REQUIRED | Data to be sent to the provided presences, or nil. |
| presences | table | REQUIRED | List of presences (a subset of match participants) to use as message targets, or 'nil' to send to the whole match. |
| sender | nkruntime.Presence | REQUIRED | A presence to tag on the message as the sender, or 'nil'. |

| Returns |
| --- |
| Name | Description |
| --- | --- |
| error | error | An optional error that may indicate a problem broadcasting data to match participants. |

|     |     |
| --- | --- |
| ```<br> 1<br> 2<br> 3<br> 4<br> 5<br> 6<br> 7<br> 8<br> 9<br>10<br>11<br>12<br>``` | ```lua<br>local nk = require("nakama")<br>function match_loop(context, dispatcher, tick, state, messages)<br>  local opcode = 1234<br>  local message = { ["hello"] = "world" }<br>  local encoded = nk.json_encode(message)<br>  local presences = nil -- send to all.<br>  local sender = nil -- used if a message should come from a specific user.<br>  dispatcher.broadcast_message(opcode, encoded, presences, sender)<br>  return state<br>end<br>``` |

### match_kick [#](/content/docs/nakama/server-framework/lua-runtime/function-reference/match-runtime/#match_kick/index.html)

Removes participants from the match. Call at any point during the match loop to remove participants based on misbehavior or other game-specific rules.

| Parameters |
| --- |
| Name | Default | Description |
| --- | --- | --- |
| presences | table | REQUIRED | A list of match participant presences to remove from the match. |

| Returns |
| --- |
| Name | Description |
| --- | --- |
| error | error | An optional error that may indicate a problem kicking the selected match participants. |

|     |     |
| --- | --- |
| ```<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>``` | ```lua<br>local nk = require("nakama")<br>function match_loop(context, dispatcher, tick, state, messages)<br>  -- Assume we store presences in state<br>  dispatcher.match_kick(state.presences)<br>  return state<br>end<br>``` |

### match_label_update [#](/content/docs/nakama/server-framework/lua-runtime/function-reference/match-runtime/#match_label_update/index.html)

Sets a new label for the match.

| Parameters |
| --- |
| Name | Default | Description |
| --- | --- | --- |
| label | string | REQUIRED | New label to set for the match. |

| Returns |
| --- |
| Name | Description |
| --- | --- |
| error | error | An optional error that may indicate a problem applying the new match label. |

|     |     |
| --- | --- |
| ```<br>1<br>2<br>3<br>4<br>5<br>6<br>``` | ```lua<br>local nk = require("nakama")<br>function match_loop(context, dispatcher, tick, state, messages)<br>  dispatcher.match_label_update("updatedlabel")<br>  return state<br>end<br>``` |
