I wish to modify Chris McCord's chat example to add additional functionality. Basically, I want the JavaScript client to have access to a number of convenience functions, such as getUsersInRoom(room_id)
, is_online(user_id)
, etc., using JSON.
But I'm not sure how to do this. The docs on Channels say that:
Each Channel will implement one or more clauses of each of these four callback functions - join/3, terminate/2, handle_in/3, and handle_out/3.
Does that mean these are the only functions allowed? I think what I need is a socket API, but I've never worked with sockets before and will appreciate some help. Also, the example seems to work on direct function calls with strings passed as arguments, but I need my chatting system to use JSON. I'm not at all sure how I can accomplish this.