-
Notifications
You must be signed in to change notification settings - Fork 3
Messages
Sending Messages - Fetch Messages From a Room - Typing Indicators
@param int $roomId
@param array $message
@return \Chess\Chatkit\Models\Message
$room->messages()->send($message);
text
(string|required): Message text.
attachment
(array|optional): Attachment to send with message
-
resource_link
(string|required): A valid URL to the resource being attached to the message. -
type
(string|required): The type of attachment. This can be one of image,video, audio or file.
Example
$room = new \Chess\Chatkit\Models\Room($roomId);
$message = $room->messages()->send([
'text' => 'Test Message',
'attachment' => [
'resource_link' => 'https://images.com/mycoolimage.jpg',
'type' => 'image'
]
]);
@param int $roomId
@param int|optional $messageId
@return \Illuminate\Support\Collection
The maximum number of messages that can be fetched is 100.
initial_id
(integer|optional): Starting id of the range of messages (non-inclusive).
limit
(integer|optional): Number of messages to return. If left empty, the limit is set to 20 by default.
direction
(string|optional): Order of messages - one of newer
or older
.
Example
$room = new \Chess\Chatkit\Models\Room($roomId);
$messages = $room->messages()->get();
OR with optional parameters. Note that you can chain the filters methods the way you like.
$room = new \Chess\Chatkit\Models\Room($roomId);
$messages = $room->messages()->fromId($messageId)->newer()->limit(5)->get();
// Is the same has this :
$messages = $room->messages()->get(['initial_id' => $messageId, 'direction' => 'newer', 'limit' => 5]);
@param int $roomId
@return bool
Examples
Start Typing
$room = new \Chess\Chatkit\Models\Room($roomId);
$typing = $room->typing()->start();
Stop Typing
$room = new \Chess\Chatkit\Models\Room($roomId);
$typing = $room->typing()->stop();