> For the complete documentation index, see [llms.txt](https://matthias.gitbook.io/matthiasdocu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://matthias.gitbook.io/matthiasdocu/callbacks.md).

# Callbacks

Callbacks are really important in an API, as they provide flexibility and customization to an extension.

### The list of callbacks you can use, with the trigger of their call as well as what argument does the callback come with:

* OnChatSend (Called when a chat is sent) Argument: The message sent by the user (Only text messages are provided in the argument, this does not mean that it is not called when sending a file.)
* OnChatReceive (Called when a chat is received) Argument: The message received [Serde](https://serde.rs/) serialized
* OnServerChatReceive (This is unused and reserved for something else in the future)
* OnCallSend (Called when the user joins a call)
* OnCallReceive (Called when there is a call started)
* OnDraw (Called every frame)
* OnConnect (Called when connecting to a server) Argument: The address the user is connecting to.
* OnDisconnect (Called when disconnecting from a server)

Please note that function arguments are "optional" that means if one does not wish to get them they can format their function accordingly.

#### Example:

```lua
function OnChatSend(message)
     --Do anything with the message
end
function OnChatSend()
     --The function will still be called
end
```
