sendMessage API allows you to send messages in one-on-one chat.
sendMessage($to,$message,$dir = 0) // $dir can be 0, 1 or 2
1. Setting $dir to 0 will send the message to both the sender and receiver. This is the default behavior of sendMessage.
include_once ('cometchat/cometchat_init.php');
sendMessage($to,'Hello!!',0);
2. Setting $dir to 1 allows you to dynamically send message (one-way) to a particular user. This message will not appear in the senders chat box screen.
include_once ('cometchat/cometchat_init.php');
sendMessage($toID,"Would you like to have a Pizza?",1);
3. Setting $dir to 2 allows you to dynamically send message (one-way) from a particular user. This message will only appear in the senders chat box screen.
Note: The $to is the user’s ID of the chat box and not the user to whom this message is being sent.
include_once ('cometchat/cometchat_init.php');
sendMessage($toID,"has successfully sent Pizza request.",2);
Not finding what you need?
The CometChat team is here to help!