久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='k63ds'></tfoot>
      <bdo id='k63ds'></bdo><ul id='k63ds'></ul>

    1. <small id='k63ds'></small><noframes id='k63ds'>

      <i id='k63ds'><tr id='k63ds'><dt id='k63ds'><q id='k63ds'><span id='k63ds'><b id='k63ds'><form id='k63ds'><ins id='k63ds'></ins><ul id='k63ds'></ul><sub id='k63ds'></sub></form><legend id='k63ds'></legend><bdo id='k63ds'><pre id='k63ds'><center id='k63ds'></center></pre></bdo></b><th id='k63ds'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='k63ds'><tfoot id='k63ds'></tfoot><dl id='k63ds'><fieldset id='k63ds'></fieldset></dl></div>

      1. <legend id='k63ds'><style id='k63ds'><dir id='k63ds'><q id='k63ds'></q></dir></style></legend>

        如何獲取特定用戶的連接對象?

        how to get the connection object of a specific user?(如何獲取特定用戶的連接對象?)

        <i id='09D95'><tr id='09D95'><dt id='09D95'><q id='09D95'><span id='09D95'><b id='09D95'><form id='09D95'><ins id='09D95'></ins><ul id='09D95'></ul><sub id='09D95'></sub></form><legend id='09D95'></legend><bdo id='09D95'><pre id='09D95'><center id='09D95'></center></pre></bdo></b><th id='09D95'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='09D95'><tfoot id='09D95'></tfoot><dl id='09D95'><fieldset id='09D95'></fieldset></dl></div>
      2. <tfoot id='09D95'></tfoot>
        • <bdo id='09D95'></bdo><ul id='09D95'></ul>
            <tbody id='09D95'></tbody>

          <small id='09D95'></small><noframes id='09D95'>

              • <legend id='09D95'><style id='09D95'><dir id='09D95'><q id='09D95'></q></dir></style></legend>

                  本文介紹了如何獲取特定用戶的連接對象?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用 Ratchet 庫的實時 Symfony 應用程序中工作,在此應用程序中,我需要向特定用戶發送一些數據,因此邏輯解決方案是使用SessionProvider 將一個 Symfony2 Session 對象附加到每個傳入的 Connection 對象.正如文檔所述,我已經設置了一個非本地會話處理程序來存儲我的會話,即通過 PDO 存儲在數據庫中.并且目前工作正常,但我需要獲取特定用戶的 Connection 對象以向他發送一些數據,因此以其他方式我需要找到引用該用戶的連接對象,但我找不到方法它 ?她是我的服務器代碼:

                  I am working in a real time Symfony app using Ratchet library, in this app I need to send some data to a specific user so the logic solution was to use the SessionProvider that will attach a Symfony2 Session object to each incoming Connection object. As the documentation states I have setup a non-native session handler to store my sessions i.e. in a database via PDO. and that work fine for the moment but I need to get the Connection object of a specific user to send him some data so in other way I need to find the connection object that reference to this user and I can't find a way to do it ? her's my server code :

                      $app=new AggregateApplication();
                      $loop   = ReactEventLoopFactory::create();
                      $context = new ReactMQContext($loop);
                      $pull = $context->getSocket(MQ::SOCKET_PULL);
                      $pull->bind('tcp://127.0.0.1:5555');
                      $pull->on('message', array($app, 'onNotification'));
                      $webSock = new ReactSocketServer($loop);
                      $webSock->listen(8080, '127.0.0.1');
                      $handler = $this->getContainer()->get('session.handler');
                      $server=new RatchetWampWampServer($app);
                      $server = new SessionProvider($server, $handler);
                      $webServer = new RatchetServerIoServer(new RatchetWebSocketWsServer($server),$webSock);
                      $loop->run();
                  

                  推薦答案

                  我自己也有同樣的問題(除了 Symfony),這就是我所做的.

                  I had the exact same question myself (minus Symfony) and here is what I did.

                  根據 hello world 教程,我用數組替換了 SplObjectStorage.在介紹我的修改之前,我想評論一下,如果您遵循該教程并理解了它,那么阻止您自己獲得此解決方案的唯一原因可能是不知道 SplObjectStorage 是.

                  Based on the hello world tutorial, I have substituted SplObjectStorage with an array. Before presenting my modifications, I'd like to comment that if you followed through that tutorial and understood it, the only thing that prevented you from arriving at this solution yourself is probably not knowing what SplObjectStorage is.

                  class Chat implements MessageComponentInterface {
                      protected $clients;
                  
                      public function __construct() {
                          $this->clients = array();
                      }
                  
                      public function onOpen(ConnectionInterface $conn) {
                          // Store the new connection to send messages to later
                          $this->clients[$conn->resourceId] = $conn;
                          echo "New connection! ({$conn->resourceId})
                  ";
                      }
                  
                      public function onMessage(ConnectionInterface $from, $msg) {
                          $numRecv = count($this->clients) - 1;
                          echo sprintf('Connection %d sending message "%s" to %d other connection%s' . "
                  "
                              , $from->resourceId, $msg, $numRecv, $numRecv == 1 ? '' : 's');
                  
                          foreach ($this->clients as $key => $client) {
                              if ($from !== $client) {
                                  // The sender is not the receiver, send to each client connected
                                  $client->send($msg);
                              }
                          }
                          // Send a message to a known resourceId (in this example the sender)
                          $client = $this->clients[$from->resourceId];
                          $client->send("Message successfully sent to $numRecv users.");
                      }
                  
                      public function onClose(ConnectionInterface $conn) {
                          // The connection is closed, remove it, as we can no longer send it messages
                          unset($this->clients[$conn->resourceId]);
                  
                          echo "Connection {$conn->resourceId} has disconnected
                  ";
                      }
                  
                      public function onError(ConnectionInterface $conn, Exception $e) {
                          echo "An error has occurred: {$e->getMessage()}
                  ";
                  
                          $conn->close();
                      }
                  }
                  

                  當然,為了讓它真正有用,您可能還想添加一個數據庫連接,并存儲/檢索這些資源 ID.

                  Of course to make it really useful you may also want to add in a DB connection, and store/retrieve those resourceIds.

                  這篇關于如何獲取特定用戶的連接對象?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                  <small id='Av6tG'></small><noframes id='Av6tG'>

                    1. <tfoot id='Av6tG'></tfoot>

                          • <bdo id='Av6tG'></bdo><ul id='Av6tG'></ul>
                              <tbody id='Av6tG'></tbody>
                          • <legend id='Av6tG'><style id='Av6tG'><dir id='Av6tG'><q id='Av6tG'></q></dir></style></legend>
                            <i id='Av6tG'><tr id='Av6tG'><dt id='Av6tG'><q id='Av6tG'><span id='Av6tG'><b id='Av6tG'><form id='Av6tG'><ins id='Av6tG'></ins><ul id='Av6tG'></ul><sub id='Av6tG'></sub></form><legend id='Av6tG'></legend><bdo id='Av6tG'><pre id='Av6tG'><center id='Av6tG'></center></pre></bdo></b><th id='Av6tG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Av6tG'><tfoot id='Av6tG'></tfoot><dl id='Av6tG'><fieldset id='Av6tG'></fieldset></dl></div>
                            主站蜘蛛池模板: 国产精品精品久久久久久 | 精品欧美一区二区三区免费观看 | 亚洲精品电影在线观看 | 亚洲免费一区二区 | 秋霞av国产精品一区 | 日韩国产免费 | 久在线精品视频 | 国产女人叫床高潮大片免费 | 成人一区二区三区 | 国产一区二区三区在线看 | 日本精品一区二区在线观看 | 欧美日韩高清免费 | 成人免费视频网站在线看 | 五月婷婷在线视频 | 久草福利 | 免费国产精品久久久久久 | 国产一区二区三区视频 | 精品国产乱码久久久久久88av | 中文在线一区二区 | 久久久久久亚洲精品 | 久久av.com| 成人免费淫片aa视频免费 | 亚洲一二三区精品 | 亚洲精品资源 | 国产一区二区三区 | 久久久久黄色 | 久久亚洲视频网 | 日韩一区二区三区在线观看 | 欧美激情精品久久久久久 | 91精品国产乱码久久久久久久久 | 五月综合激情在线 | 亚洲小视频 | 国产精品久久av | 亚洲综合视频一区 | 一区二区国产在线观看 | 99re6在线视频 | 国产精品视频中文字幕 | 午夜精品久久久久久久星辰影院 | 日韩1区2区 | 一区视频在线 | 亚洲国产网站 |