Adding custom functions to channels

I’m wondering if it’s possible to add custom functions to Phoenix channels? Basically, I’d like my chat server to expose some convenience functions like getUsersInRoom(room_id) and isOnline(user_id) and I have no clue how this can be done.

Can anyone explain what I need to do for this at the server end? And and the client end?

1 Like

You might already have an event like "new_message", just add another one like "users_in_room".

1 Like

Very interesting. I think I need to look into channels in more detail. Will read and come back if I still have doubts. :slight_smile:

Thank you, indeed! That was what I was looking for. :grin:

For those viewing this thread later, what I needed was a way to add custom events to the channel. My question, however, looks confusing because it reflected my ignorance – it wasn’t functions that I needed!