作者 潘浩文
1 个管道 的构建 通过 耗费 0 秒

websocket协议测试

@@ -31,7 +31,8 @@ @@ -31,7 +31,8 @@
31 "weiwei/api-doc": "^1.6", 31 "weiwei/api-doc": "^1.6",
32 "hooklife/thinkphp5-wechat": "^1.1", 32 "hooklife/thinkphp5-wechat": "^1.1",
33 "topthink/think-worker": "^2.0", 33 "topthink/think-worker": "^2.0",
34 - "workerman/workerman-for-win": "^3.5" 34 + "workerman/workerman-for-win": "^3.5",
  35 + "topthink/think-orm": "^1.2"
35 }, 36 },
36 "extra": { 37 "extra": {
37 }, 38 },
1 <?php 1 <?php
2 use Workerman\Worker; 2 use Workerman\Worker;
3 use think\Db; 3 use think\Db;
  4 +// 数据库配置信息设置(全局有效)
  5 +
4 require_once __DIR__ . '/simplewind/vendor/workerman/workerman/Autoloader.php'; 6 require_once __DIR__ . '/simplewind/vendor/workerman/workerman/Autoloader.php';
5 7
6 //$global_uid = 0; 8 //$global_uid = 0;
@@ -122,7 +124,7 @@ require_once __DIR__ . '/simplewind/vendor/workerman/workerman/Autoloader.php'; @@ -122,7 +124,7 @@ require_once __DIR__ . '/simplewind/vendor/workerman/workerman/Autoloader.php';
122 124
123 // 创建一个Worker监听2347端口,不使用任何应用层协议 125 // 创建一个Worker监听2347端口,不使用任何应用层协议
124 $tcp_worker = new Worker("websocket://114.215.223.17:5001"); 126 $tcp_worker = new Worker("websocket://114.215.223.17:5001");
125 - 127 +//Db::setConfig(['数据库配置参数(数组)']);
126 //$tcp_worker->name='panhaowen'; 128 //$tcp_worker->name='panhaowen';
127 // 启动4个进程对外提供服务 129 // 启动4个进程对外提供服务
128 $tcp_worker->count = 1; 130 $tcp_worker->count = 1;
@@ -131,7 +133,7 @@ $tcp_worker->count = 1; @@ -131,7 +133,7 @@ $tcp_worker->count = 1;
131 $tcp_worker->onMessage = function($connection, $data) 133 $tcp_worker->onMessage = function($connection, $data)
132 { 134 {
133 // 向客户端发送hello $data 135 // 向客户端发送hello $data
134 - $connection->send('hello ' . $data); 136 + $connection->send('hello '. $data);
135 if ($data=='tom') { 137 if ($data=='tom') {
136 Db::name('user')->where('id',1)->update(['sex'=>1]); 138 Db::name('user')->where('id',1)->update(['sex'=>1]);
137 } 139 }
@@ -18,6 +18,7 @@ return array( @@ -18,6 +18,7 @@ return array(
18 'b248b9358a8992876b21eddc15455b97' => $vendorDir . '/hooklife/thinkphp5-wechat/src/helper.php', 18 'b248b9358a8992876b21eddc15455b97' => $vendorDir . '/hooklife/thinkphp5-wechat/src/helper.php',
19 '841780ea2e1d6545ea3a253239d59c05' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/functions.php', 19 '841780ea2e1d6545ea3a253239d59c05' => $vendorDir . '/qiniu/php-sdk/src/Qiniu/functions.php',
20 '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', 20 '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php',
  21 + '33197a0023ced5fbf8f861d1c4ca048d' => $vendorDir . '/topthink/think-orm/src/config.php',
21 'ffc1d7141d4fcbaeb47a6929f0811ed1' => $vendorDir . '/topthink/think-worker/src/command.php', 22 'ffc1d7141d4fcbaeb47a6929f0811ed1' => $vendorDir . '/topthink/think-worker/src/command.php',
22 '644e9cafc67b331e17cc7661548f33d0' => $vendorDir . '/weiwei/api-doc/src/helper.php', 23 '644e9cafc67b331e17cc7661548f33d0' => $vendorDir . '/weiwei/api-doc/src/helper.php',
23 ); 24 );
@@ -10,7 +10,7 @@ return array( @@ -10,7 +10,7 @@ return array(
10 'think\\helper\\' => array($vendorDir . '/topthink/think-helper/src'), 10 'think\\helper\\' => array($vendorDir . '/topthink/think-helper/src'),
11 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 11 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
12 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 12 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
13 - 'think\\' => array($vendorDir . '/topthink/think-image/src'), 13 + 'think\\' => array($vendorDir . '/topthink/think-image/src', $vendorDir . '/topthink/think-orm/src'),
14 'mindplay\\annotations\\' => array($vendorDir . '/mindplay/annotations/src/annotations'), 14 'mindplay\\annotations\\' => array($vendorDir . '/mindplay/annotations/src/annotations'),
15 'Workerman\\' => array($vendorDir . '/workerman/workerman', $vendorDir . '/workerman/workerman-for-win'), 15 'Workerman\\' => array($vendorDir . '/workerman/workerman', $vendorDir . '/workerman/workerman-for-win'),
16 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'), 16 'Symfony\\Polyfill\\Php70\\' => array($vendorDir . '/symfony/polyfill-php70'),
@@ -19,6 +19,7 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7 @@ -19,6 +19,7 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7
19 'b248b9358a8992876b21eddc15455b97' => __DIR__ . '/..' . '/hooklife/thinkphp5-wechat/src/helper.php', 19 'b248b9358a8992876b21eddc15455b97' => __DIR__ . '/..' . '/hooklife/thinkphp5-wechat/src/helper.php',
20 '841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php', 20 '841780ea2e1d6545ea3a253239d59c05' => __DIR__ . '/..' . '/qiniu/php-sdk/src/Qiniu/functions.php',
21 '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', 21 '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php',
  22 + '33197a0023ced5fbf8f861d1c4ca048d' => __DIR__ . '/..' . '/topthink/think-orm/src/config.php',
22 'ffc1d7141d4fcbaeb47a6929f0811ed1' => __DIR__ . '/..' . '/topthink/think-worker/src/command.php', 23 'ffc1d7141d4fcbaeb47a6929f0811ed1' => __DIR__ . '/..' . '/topthink/think-worker/src/command.php',
23 '644e9cafc67b331e17cc7661548f33d0' => __DIR__ . '/..' . '/weiwei/api-doc/src/helper.php', 24 '644e9cafc67b331e17cc7661548f33d0' => __DIR__ . '/..' . '/weiwei/api-doc/src/helper.php',
24 ); 25 );
@@ -114,6 +115,7 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7 @@ -114,6 +115,7 @@ class ComposerStaticInit929fb365b9981d29459d58f676689cf7
114 'think\\' => 115 'think\\' =>
115 array ( 116 array (
116 0 => __DIR__ . '/..' . '/topthink/think-image/src', 117 0 => __DIR__ . '/..' . '/topthink/think-image/src',
  118 + 1 => __DIR__ . '/..' . '/topthink/think-orm/src',
117 ), 119 ),
118 'mindplay\\annotations\\' => 120 'mindplay\\annotations\\' =>
119 array ( 121 array (
@@ -1684,6 +1684,47 @@ @@ -1684,6 +1684,47 @@
1684 ] 1684 ]
1685 }, 1685 },
1686 { 1686 {
  1687 + "name": "topthink/think-orm",
  1688 + "version": "v1.2.12",
  1689 + "version_normalized": "1.2.12.0",
  1690 + "source": {
  1691 + "type": "git",
  1692 + "url": "https://github.com/top-think/think-orm.git",
  1693 + "reference": "7c1de8b1045ecdd3a9a2b0a7713cae95f68db85d"
  1694 + },
  1695 + "dist": {
  1696 + "type": "zip",
  1697 + "url": "https://api.github.com/repos/top-think/think-orm/zipball/7c1de8b1045ecdd3a9a2b0a7713cae95f68db85d",
  1698 + "reference": "7c1de8b1045ecdd3a9a2b0a7713cae95f68db85d",
  1699 + "shasum": ""
  1700 + },
  1701 + "require": {
  1702 + "php": ">=5.6.0"
  1703 + },
  1704 + "time": "2018-10-18T02:26:56+00:00",
  1705 + "type": "library",
  1706 + "installation-source": "dist",
  1707 + "autoload": {
  1708 + "psr-4": {
  1709 + "think\\": "src"
  1710 + },
  1711 + "files": [
  1712 + "src/config.php"
  1713 + ]
  1714 + },
  1715 + "notification-url": "https://packagist.org/downloads/",
  1716 + "license": [
  1717 + "Apache-2.0"
  1718 + ],
  1719 + "authors": [
  1720 + {
  1721 + "name": "liu21st",
  1722 + "email": "liu21st@gmail.com"
  1723 + }
  1724 + ],
  1725 + "description": "think orm"
  1726 + },
  1727 + {
1687 "name": "topthink/think-worker", 1728 "name": "topthink/think-worker",
1688 "version": "v2.0.10", 1729 "version": "v2.0.10",
1689 "version_normalized": "2.0.10.0", 1730 "version_normalized": "2.0.10.0",