コード例 #1
0
ファイル: PoprigunChatMessage.php プロジェクト: poprigun/chat
 /**
  * Send message
  * @param string|null $title
  * @return bool
  */
 public function sendMessage($title = null)
 {
     try {
         switch ($this->messageType) {
             case self::MESSAGE_TO_USER:
                 $dialog = PoprigunChatDialog::getMessageDialog($this->author_id, $this->receiverId, $title);
                 break;
             case self::MESSAGE_TO_DIALOG:
                 $dialog = PoprigunChatDialog::getDialog($this->author_id, $this->receiverId);
                 if (null === $dialog) {
                     throw new \BadMethodCallException();
                 }
                 break;
             default:
                 throw new \BadMethodCallException();
         }
         $result = $dialog->addMessageToDialog($this->author_id, $this->message);
     } catch (\Exception $e) {
         $result = $e->getMessage();
     }
     return $result;
 }