Esempio n. 1
0
 public function registerAssets()
 {
     $view = $this->getView();
     ChatAssets::register($view);
     Yii::$app->session->set(self::$sessionName, ChatAssets::register($view)->baseUrl);
     echo $this->renderFile($this->template, ['options' => $this->options]);
 }
Esempio n. 2
0
 public function registerAssets()
 {
     $view = $this->getView();
     if ($this->node) {
         $this->options['rooms'] = self::generateRoomIds(Yii::$app->user->id, PoprigunChatDialog::getUserDialogs(Yii::$app->user->id));
         $this->options['socketUrl'] = isset($this->socketUrl) ? $this->count : 'http://' . $_SERVER['SERVER_ADDR'] . ':8080';
         ChatAssets::register($view);
     } else {
         ChatWithoutNodeAssets::register($view);
     }
     $script = '
          poprigunChat = new PoprigunChat(' . Json::encode($this->options) . ');
     ';
     $view->registerJs($script, View::POS_END);
     echo $this->renderFile($this->template, ['model' => new PoprigunChatMessage(), 'options' => $this->options, 'rooms' => self::generateRoomIds(Yii::$app->user->id, PoprigunChatDialog::getUserDialogs(Yii::$app->user->id))]);
 }