Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mpociot/slack-client
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed May 4, 2017
2 parents 76296d7 + 906d979 commit 33cee41
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/RealTimeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,36 @@ public function postMessage(Message $message)
return $deferred->promise();
}

/**
* Set as typing
*
* @param \Slack\ChannelInterface $channel The channel to set typing indicator in.
* @param bool $callDeferred Whether to call the API asynchronous or not.
*
* @return \React\Promise\PromiseInterface
*/
public function setAsTyping(ChannelInterface $channel, $callDeferred = true)
{
if (!$this->connected) {
return Promise\reject(new ConnectionException('Client not connected. Did you forget to call `connect()`?'));
}

$data = [
'id' => ++$this->lastMessageId,
'type' => 'typing',
'channel' => $channel->data['id'],
];
$this->websocket->send(json_encode($data));

// Perform an iteration of the event loop in order to send the
// web socket message synchronously
if (!$callDeferred) {
$this->loop->tick();
}

return Promise\resolve();
}

/**
* Returns whether the client is connected.
*
Expand Down

0 comments on commit 33cee41

Please sign in to comment.