pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <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="bpr91xz" 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>

        如何獲取特定用戶的連接對(duì)象?

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

        <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="1hnxxrt" 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>

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

                  問題描述

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

                  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.

                  根據(jù) hello world 教程,我用數(shù)組替換了 SplObjectStorage.在介紹我的修改之前,我想評(píng)論一下,如果您遵循該教程并理解了它,那么阻止您自己獲得此解決方案的唯一原因可能是不知道 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();
                      }
                  }
                  

                  當(dāng)然,為了讓它真正有用,您可能還想添加一個(gè)數(shù)據(jù)庫連接,并存儲(chǔ)/檢索這些資源 ID.

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

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

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

                  相關(guān)文檔推薦

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

                  <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="b7hb57d" id='Av6tG'><tfoot id='Av6tG'></tfoot><dl id='Av6tG'><fieldset id='Av6tG'></fieldset></dl></div>
                            主站蜘蛛池模板: 中药超微粉碎机(中药细胞级微粉碎)-百科 | 最新电影-好看的电视剧大全-朝夕电影网 | 南昌旅行社_南昌国际旅行社_南昌国旅在线| 上海风淋室_上海风淋室厂家_上海风淋室价格_上海伯淋 | 防火板_饰面耐火板价格、厂家_品牌认准格林雅 | 中式装修设计_全屋定制家具_实木仿古门窗花格厂家-喜迎门 | 气动球阀_衬氟蝶阀_调节阀_电动截止阀_上海沃托阀门有限公司 | 上海平衡机-单面卧式动平衡机-万向节动平衡机-圈带动平衡机厂家-上海申岢动平衡机制造有限公司 | RS系列电阻器,RK_RJ启动调整电阻器,RQ_RZ电阻器-上海永上电器有限公司 | ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 广州中央空调回收,二手中央空调回收,旧空调回收,制冷设备回收,冷气机组回收公司-广州益夫制冷设备回收公司 | 四探针电阻率测试仪-振实密度仪-粉末流动性测定仪-宁波瑞柯微智能 | 恒温恒湿试验箱_高低温试验箱_恒温恒湿箱-东莞市高天试验设备有限公司 | 缠绕机|缠绕膜包装机|缠绕包装机-上海晏陵智能设备有限公司 | 福州仿石漆加盟_福建仿石漆厂家-外墙仿石漆加盟推荐铁壁金钢(福建)新材料科技有限公司有保障 | 沈阳缠绕包装机厂家直销-沈阳海鹞托盘缠绕包装机价格 | 滑板场地施工_极限运动场地设计_滑板公园建造_盐城天人极限运动场地建设有限公司 | 并离网逆变器_高频UPS电源定制_户用储能光伏逆变器厂家-深圳市索克新能源 | 集装箱展厅-住人集装箱住宿|建筑|房屋|集装箱售楼处-山东锐嘉科技工程有限公司 | 泰国试管婴儿_泰国第三代试管婴儿费用|成功率|医院—新生代海外医疗 | led太阳能路灯厂家价格_风光互补庭院灯_农村市政工程路灯-中山华可路灯品牌 | 活性氧化铝|无烟煤滤料|活性氧化铝厂家|锰砂滤料厂家-河南新泰净水材料有限公司 | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 烟雾净化器-滤筒除尘器-防爆除尘器-除尘器厂家-东莞执信环保科技有限公司 | 生产自动包装秤_颗粒包装秤_肥料包装秤等包装机械-郑州鑫晟重工科技有限公司 | 六维力传感器_三维力传感器_二维力传感器-南京神源生智能科技有限公司 | 电动手术床,医用护理床,led手术无影灯-曲阜明辉医疗设备有限公司 | 济南ISO9000认证咨询代理公司,ISO9001认证,CMA实验室认证,ISO/TS16949认证,服务体系认证,资产管理体系认证,SC食品生产许可证- 济南创远企业管理咨询有限公司 郑州电线电缆厂家-防火|低压|低烟无卤电缆-河南明星电缆 | 单级/双级旋片式真空泵厂家,2xz旋片真空泵-浙江台州求精真空泵有限公司 | 厦门网站建设_厦门网站设计_小程序开发_网站制作公司【麦格科技】 | 棉柔巾代加工_洗脸巾oem_一次性毛巾_浴巾生产厂家-杭州禾壹卫品科技有限公司 | 电动百叶窗,开窗器,电动遮阳百叶,电动开窗机生产厂家-徐州鑫友工控科技发展有限公司 | 中国产业发展研究网 - 提供行业研究报告 可行性研究报告 投资咨询 市场调研服务 | 安徽免检低氮锅炉_合肥燃油锅炉_安徽蒸汽发生器_合肥燃气锅炉-合肥扬诺锅炉有限公司 | 河南卓美创业科技有限公司-河南卓美防雷公司-防雷接地-防雷工程-重庆避雷针-避雷器-防雷检测-避雷带-避雷针-避雷塔、机房防雷、古建筑防雷等-山西防雷公司 | 集装箱箱号识别_自重载重图像识别_铁路车号自动识别_OCR图像识别 | 撕碎机_轮胎破碎机_粉碎机_回收生产线厂家_东莞华达机械有限公司 | 幂简集成 - 品种超全的API接口平台, 一站搜索、试用、集成国内外API接口 | 酵素生产厂家_酵素OEM_酵素加盟_酵素ODM_酵素原料厂家_厦门益力康 | 网站优化公司_北京网站优化_抖音短视频代运营_抖音关键词seo优化排名-通则达网络 | 背压阀|减压器|不锈钢减压器|减压阀|卫生级背压阀|单向阀|背压阀厂家-上海沃原自控阀门有限公司 本安接线盒-本安电路用接线盒-本安分线盒-矿用电话接线盒-JHH生产厂家-宁波龙亿电子科技有限公司 |