/**
  * @param User $user
  * @param UserCollection $userCollection
  */
 public function notifyChat(User $user, UserCollection $userCollection)
 {
     $channelId = $user->getChannelId();
     DI::get()->getLogger()->info("Total user count {$userCollection->getTotalCount()}", [__CLASS__]);
     if ($user->isInPrivateChat()) {
         $dualUsers = new UserCollection();
         $dualUsers->attach($user);
         $response = (new MessageResponse())->setTime(null)->setGuests($userCollection->getUsersByChatId($channelId))->setChannelId($channelId);
         if ($userCollection->getClientsCount($channelId) > 1) {
             $dualUsers = $userCollection;
             $response->setMsg(MsgToken::create('PartnerIsOnline'))->setDualChat('match');
         } elseif ($num = PendingDuals::get()->getUserPosition($user)) {
             $response->setMsg(MsgToken::create('StillInDualSearch', $num))->setDualChat('init');
         } else {
             $response->setMsg(MsgToken::create('YouAreAlone'))->setDualChat('match');
         }
         if ($user->getLastMsgId()) {
             $response->setMsg(Msg::create(null));
         }
         $dualUsers->setResponse($response)->notify(false);
     } else {
         ChannelNotifier::welcome($user, $userCollection);
         ChannelNotifier::indentifyChat($user, $userCollection, true);
     }
 }
 private function sendPublic(UserCollection $clients, User $user, $msg, $isSelf)
 {
     $props = $user->getProperties();
     $filteredMsg = RudeFilter::parse($msg);
     if (mb_strlen($filteredMsg) != mb_strlen($msg)) {
         $props->setRudeCount($props->getRudeCount() + 1);
     }
     $props->setWordsCount($props->getWordsCount() + mb_substr_count($msg, ' ') + 1);
     $response = (new MessageResponse())->setMsg(Msg::create($msg))->setFilteredMsg(Msg::create($filteredMsg))->setTime(null)->setChannelId($user->getChannelId());
     if (!$isSelf) {
         $response->setFrom($user);
     }
     $clients->setResponse($response)->notify();
 }