• Как отключить SSl для ip?

    @DEnisLEB Автор вопроса
    его нет... по этому адресу /etc/apache2/sites-available/default-ssl
  • Конфликт MySql и WebSocket, как решить?

    @DEnisLEB Автор вопроса
    Александр Аксентьев, изи решение хочешь? \R::close();
  • Конфликт MySql и WebSocket, как решить?

    @DEnisLEB Автор вопроса
    Дело в том, что даже если на переменной ничего не завязано, крашится( даже если переменная не отвечает не за что)
  • Как изменить принцип генерации ключа соединения Ratchet WebSockets?

    @DEnisLEB Автор вопроса
    hOtRush, Я так понял этот сокет кеширует все переменные? Если да, то как при событие закрытия удалить переменную события открытия? После перезагрузки страницы проверка проводится со старыми значениями
    $Cookie = $conn->WebSocket->request->getCookies('Cookie');
    
    
      if ((isset($Cookie['id'])) && (isset($Cookie['hash'])) && (empty($conn->resourceId))){
        if ((!empty($Cookie['id'])) && (!empty($Cookie['hash']))){
      $ss = \R::findOne( 'user', ' id = ? ', array($Cookie['id']));
           if(!empty($ss) && $Cookie['hash'] == $ss->hash ){
             if($ss->type != 0){
               if($ss->type == 6){
              header('Location: http://'.$_SERVER['SERVER_NAME'].'/ban');
               }else{
    $conn->resourceId = $Cookie['id'];
    $this->clients->attach($conn);
    echo "New ! ({$conn->resourceId})\n";
                }
             }else{
              // ваш аккаун не активирован проверь почту
    $conn->resourceId = $Cookie['id'];
    $this->clients->attach($conn);
    echo "New ! ({$conn->resourceId})\n";
             }
           }else{
    //Разрыв соединения
    $Cookie = null;
    $ss = null;
    $this->clients->detach($conn);
    echo "Connection {$conn->resourceId} has disconnected\n";
           }
          }else{
    //Разрыв соединения
    $Cookie = null;
    $ss = null;
    $this->clients->detach($conn);
    echo "Connection {$conn->resourceId} has disconnected\n";
          }
      }else{
      //Разрыв соединения
      $Cookie = null;
      $ss = null;
      $this->clients->detach($conn);
      echo "Connection {$conn->resourceId} has disconnected\n";
      }
    
    
    }
  • Как изменить принцип генерации ключа соединения Ratchet WebSockets?

    @DEnisLEB Автор вопроса
    hOtRush, в блокирующем) если нет человека в базе, или он не проходит проверки... фиг он отправит
  • Как изменить принцип генерации ключа соединения Ratchet WebSockets?

    @DEnisLEB Автор вопроса
    hOtRush, Это библиотека подключения к базе, из корневого файла подключение работает.
    Вот рабочий вариант,
    <?php
    use Ratchet\Server\IoServer;
    use Ratchet\Http\HttpServer;
    use Ratchet\WebSocket\WsServer;
    use MyApp\Chat;
    
       require "D:/user/tlogi/websocket/config.php";
       $sm  = R::findOne( 'user', ' id = ? ',array("2"));
       echo $sm;
       
       
    require "D:/user/tlogi/websocket/vendor/autoload.php";
    $server = IoServer::factory(
      new HttpServer(
        new WsServer(
          new Chat()
        )
      ),
      8080
    );
    
    $server->run();
    ?>
    А вот так крашит, тип не видит библиотеку, хотя код тот же  (101-104)

    <?php
    namespace Ratchet\Server;
    use Ratchet\MessageComponentInterface;
    use React\EventLoop\LoopInterface;
    use React\Socket\ServerInterface;
    use React\EventLoop\Factory as LoopFactory;
    use React\Socket\Server as Reactor;
    
    
    
    /**
     * Creates an open-ended socket to listen on a port for incoming connections.
     * Events are delegated through this to attached applications
     */
    class IoServer {
        /**
         * @var \React\EventLoop\LoopInterface
         */
        public $loop;
    
        /**
         * @var \Ratchet\MessageComponentInterface
         */
        public $app;
    
        /**
         * Array of React event handlers
         * @var \SplFixedArray
         */
        protected $handlers;
    
        /**
         * The socket server the Ratchet Application is run off of
         * @var \React\Socket\ServerInterface
         */
        public $socket;
    
        /**
         * @param \Ratchet\MessageComponentInterface  $app      The Ratchet application stack to host
         * @param \React\Socket\ServerInterface       $socket   The React socket server to run the Ratchet application off of
         * @param \React\EventLoop\LoopInterface|null $loop     The React looper to run the Ratchet application off of
         */
        public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) {
            if (false === strpos(PHP_VERSION, "hiphop")) {
                gc_enable();
    			
            }
    
            set_time_limit(0);
            ob_implicit_flush();
    
            $this->loop = $loop;
            $this->app  = $app;
            $this->socket = $socket;
    
            $socket->on('connection', array($this, 'handleConnect'));
    
            $this->handlers = new \SplFixedArray(3);
            $this->handlers[0] = array($this, 'handleData');
            $this->handlers[1] = array($this, 'handleEnd');
            $this->handlers[2] = array($this, 'handleError');
    
        }
    
        /**
         * @param  \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received
         * @param  int                                $port      The port to server sockets on
         * @param  string                             $address   The address to receive sockets on (0.0.0.0 means receive connections from any)
         * @return IoServer
         */
        public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') {
            $loop   = LoopFactory::create();
            $socket = new Reactor($loop);
            $socket->listen($port, $address);
    
            return new static($component, $socket, $loop);
        }
    
        /**
         * Run the application by entering the event loop
         * @throws \RuntimeException If a loop was not previously specified
         */
        public function run() {
            if (null === $this->loop) {
                throw new \RuntimeException("A React Loop was not provided during instantiation");
            }
    
            // @codeCoverageIgnoreStart
            $this->loop->run();
            // @codeCoverageIgnoreEnd
        }
    
        /**
         * Triggered when a new connection is received from React
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleConnect($conn) {
            $conn->decor = new IoConnection($conn);
    //задаем номер соединения
    
      require "D:/user/tlogi/websocket/config.php";
       $sm  = R::findOne( 'user', ' id = ? ',array("2"));
       
       $conn->decor->resourceId = $sm;
    
    
    
    //задаем номер соединения
            $conn->decor->remoteAddress = $conn->getRemoteAddress();
    
            $this->app->onOpen($conn->decor);
    
            $conn->on('data', $this->handlers[0]);
            $conn->on('end', $this->handlers[1]);
            $conn->on('error', $this->handlers[2]);
        }
    
        /**
         * Data has been received from React
         * @param string                            $data
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleData($data, $conn) {
            try {
                $this->app->onMessage($conn->decor, $data);
            } catch (\Exception $e) {
                $this->handleError($e, $conn);
            }
        }
    
        /**
         * A connection has been closed by React
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleEnd($conn) {
            try {
                $this->app->onClose($conn->decor);
            } catch (\Exception $e) {
                $this->handleError($e, $conn);
            }
    
            unset($conn->decor);
        }
    
        /**
         * An error has occurred, let the listening application know
         * @param \Exception                        $e
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleError(\Exception $e, $conn) {
            $this->app->onError($conn->decor, $e);
        }
    }
  • Как можно использовать библиотеку внутри другой(которая имеет пространство имен)?

    @DEnisLEB Автор вопроса
    Радость моя, дак я ведь подключаю файл через req оттуда должен класс браться
  • Как изменить принцип генерации ключа соединения Ratchet WebSockets?

    @DEnisLEB Автор вопроса
    hOtRush, а вот с базой как? Библиотека в корневом файле работает, но вот в loserver нет,... Мне кажется проблема в namespace или use (методом тыка) без них работает...
    https://ibb.co/bt8KF9/
  • Как изменить принцип генерации ключа соединения Ratchet WebSockets?

    @DEnisLEB Автор вопроса
    Почему не работает подобное решение?
    DbTroin.php
    <?
      require $_SERVER['DOCUMENT_ROOT']."/config/config.php";
      if(isset($_COOKIE['id']) && isset($_COOKIE['hash'])){
        if(!empty($_COOKIE['id']) && !empty($_COOKIE['hash'])){
         $sddd = R::findOne( 'user', ' id = ? ', array($_COOKIE['id']));
         if($sddd->hash == $_COOKIE['hash']){
      $STid = $_COOKIE['id'];
         }else{
           //ошибка безопасности
         }
        }else{
          //ошибка безопасности
        }
      }else{
        //ошибка безопасности
      }


    IoServer.php (101-102 строка)
    <?php
    namespace Ratchet\Server;
    use Ratchet\MessageComponentInterface;
    use React\EventLoop\LoopInterface;
    use React\Socket\ServerInterface;
    use React\EventLoop\Factory as LoopFactory;
    use React\Socket\Server as Reactor;
    
    
    
    
    /**
     * Creates an open-ended socket to listen on a port for incoming connections.
     * Events are delegated through this to attached applications
     */
    class IoServer {
        /**
         * @var \React\EventLoop\LoopInterface
         */
        public $loop;
    
        /**
         * @var \Ratchet\MessageComponentInterface
         */
        public $app;
    
        /**
         * Array of React event handlers
         * @var \SplFixedArray
         */
        protected $handlers;
    
        /**
         * The socket server the Ratchet Application is run off of
         * @var \React\Socket\ServerInterface
         */
        public $socket;
    
        /**
         * @param \Ratchet\MessageComponentInterface  $app      The Ratchet application stack to host
         * @param \React\Socket\ServerInterface       $socket   The React socket server to run the Ratchet application off of
         * @param \React\EventLoop\LoopInterface|null $loop     The React looper to run the Ratchet application off of
         */
        public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) {
            if (false === strpos(PHP_VERSION, "hiphop")) {
                gc_enable();
            }
    
            set_time_limit(0);
            ob_implicit_flush();
    
            $this->loop = $loop;
            $this->app  = $app;
            $this->socket = $socket;
    
            $socket->on('connection', array($this, 'handleConnect'));
    
            $this->handlers = new \SplFixedArray(3);
            $this->handlers[0] = array($this, 'handleData');
            $this->handlers[1] = array($this, 'handleEnd');
            $this->handlers[2] = array($this, 'handleError');
    
        }
    
        /**
         * @param  \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received
         * @param  int                                $port      The port to server sockets on
         * @param  string                             $address   The address to receive sockets on (0.0.0.0 means receive connections from any)
         * @return IoServer
         */
        public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') {
            $loop   = LoopFactory::create();
            $socket = new Reactor($loop);
            $socket->listen($port, $address);
    
            return new static($component, $socket, $loop);
        }
    
        /**
         * Run the application by entering the event loop
         * @throws \RuntimeException If a loop was not previously specified
         */
        public function run() {
            if (null === $this->loop) {
                throw new \RuntimeException("A React Loop was not provided during instantiation");
            }
    
            // @codeCoverageIgnoreStart
            $this->loop->run();
            // @codeCoverageIgnoreEnd
        }
    
        /**
         * Triggered when a new connection is received from React
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleConnect($conn) {
            $conn->decor = new IoConnection($conn);
    //задаем номер соединения
    
    
    require_once($_SERVER['DOCUMENT_ROOT']."/config/DbTroin.php");
            $conn->decor->resourceId    =  $STid;
    
    
    
    //задаем номер соединения
            $conn->decor->remoteAddress = $conn->getRemoteAddress();
    
            $this->app->onOpen($conn->decor);
    
            $conn->on('data', $this->handlers[0]);
            $conn->on('end', $this->handlers[1]);
            $conn->on('error', $this->handlers[2]);
        }
    
        /**
         * Data has been received from React
         * @param string                            $data
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleData($data, $conn) {
            try {
                $this->app->onMessage($conn->decor, $data);
            } catch (\Exception $e) {
                $this->handleError($e, $conn);
            }
        }
    
        /**
         * A connection has been closed by React
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleEnd($conn) {
            try {
                $this->app->onClose($conn->decor);
            } catch (\Exception $e) {
                $this->handleError($e, $conn);
            }
    
            unset($conn->decor);
        }
    
        /**
         * An error has occurred, let the listening application know
         * @param \Exception                        $e
         * @param \React\Socket\ConnectionInterface $conn
         */
        public function handleError(\Exception $e, $conn) {
            $this->app->onError($conn->decor, $e);
        }
    }

    Переменная по прямой ссылке на обработчик известна
  • Как изменить принцип генерации ключа соединения Ratchet WebSockets?

    @DEnisLEB Автор вопроса
    Можно ещё один вопрос? Где можно запарсить сообщение для записи в базу?
  • Как работает цикл с запросом в базу?

    @DEnisLEB Автор вопроса
    нет. я собираюсь обращаться.
    while($last_msg_id <= $old_msg_id)
    {
    usleep(200000);
    clearstatcache();
    $result = R::findLast('messages', 'dialog = ? ',array($_GET['getmess']));
    $last_msg_id = $result->date; // обновляем переменную
    } не работает
  • Как преобразовать вложения в сообщениях в html?

    @DEnisLEB Автор вопроса
    Stalker_RED, Как вывести "Привет дорогой друг, давно тебе не писал. <&&*>text<*&&> <&&*>text1<*&&>"
    text и text1?
  • Как преобразовать вложения в сообщениях в html?

    @DEnisLEB Автор вопроса
    Stalker_RED, Не почтовый клиент, а подобие чата/ форума... там тоже есть вложения же