lzj500 лет назад: 3
Родитель
Сommit
6e6a32b5c3
69 измененных файлов с 14686 добавлено и 66 удалено
  1. 1 0
      .example.env
  2. 5 64
      .gitignore
  3. 42 0
      .travis.yml
  4. 32 0
      LICENSE.txt
  5. 55 2
      README.md
  6. 1 0
      app/.htaccess
  7. 22 0
      app/AppService.php
  8. 94 0
      app/BaseController.php
  9. 58 0
      app/ExceptionHandle.php
  10. 8 0
      app/Request.php
  11. 51 0
      app/command/Base.php
  12. 33 0
      app/command/WebSocketClient.php
  13. 35 0
      app/command/WebSocketServer.php
  14. 2 0
      app/common.php
  15. 2 0
      app/common/common.php
  16. 12 0
      app/common/controller/Index.php
  17. 5 0
      app/common/event.php
  18. 5 0
      app/common/middleware.php
  19. 123 0
      app/common/workman/Tlv.php
  20. 70 0
      app/common/workman/WebSocketClient.php
  21. 58 0
      app/common/workman/WebSocketServer.php
  22. 17 0
      app/controller/Index.php
  23. 17 0
      app/event.php
  24. 10 0
      app/middleware.php
  25. 9 0
      app/provider.php
  26. 9 0
      app/service.php
  27. 2 0
      app/websocket/common.php
  28. 12 0
      app/websocket/controller/Index.php
  29. 5 0
      app/websocket/event.php
  30. 5 0
      app/websocket/middleware.php
  31. 50 0
      composer.json
  32. 1167 0
      composer.lock
  33. 32 0
      config/app.php
  34. 29 0
      config/cache.php
  35. 11 0
      config/console.php
  36. 20 0
      config/cookie.php
  37. 60 0
      config/database.php
  38. 24 0
      config/filesystem.php
  39. 27 0
      config/lang.php
  40. 45 0
      config/log.php
  41. 8 0
      config/middleware.php
  42. 45 0
      config/route.php
  43. 19 0
      config/session.php
  44. 10 0
      config/trace.php
  45. 25 0
      config/view.php
  46. 2 0
      extend/.gitignore
  47. 23 0
      html/websocket_client/.gitignore
  48. 24 0
      html/websocket_client/README.md
  49. 5 0
      html/websocket_client/babel.config.js
  50. 11938 0
      html/websocket_client/package-lock.json
  51. 43 0
      html/websocket_client/package.json
  52. BIN
      html/websocket_client/public/favicon.ico
  53. 17 0
      html/websocket_client/public/index.html
  54. 29 0
      html/websocket_client/src/App.vue
  55. BIN
      html/websocket_client/src/assets/logo.png
  56. 58 0
      html/websocket_client/src/components/HelloWorld.vue
  57. 68 0
      html/websocket_client/src/components/web-socket.vue
  58. 8 0
      html/websocket_client/src/main.js
  59. 8 0
      public/.htaccess
  60. BIN
      public/favicon.ico
  61. 24 0
      public/index.php
  62. 2 0
      public/robots.txt
  63. 19 0
      public/router.php
  64. 2 0
      public/static/.gitignore
  65. 17 0
      route/app.php
  66. 2 0
      runtime/.gitignore
  67. 10 0
      think
  68. 1 0
      view/README.md
  69. 14 0
      说明.txt

+ 1 - 0
.example.env

@@ -0,0 +1 @@
+APP_DEBUG = true

[APP]
DEFAULT_TIMEZONE = Asia/Shanghai

[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true

[LANG]
default_lang = zh-cn

+ 5 - 64
.gitignore

@@ -1,64 +1,5 @@
-# ---> PhpStorm
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff:
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/dictionaries
-
-# Sensitive or high-churn files:
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.xml
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-
-# Gradle:
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# CMake
-cmake-build-debug/
-
-# Mongo Explorer plugin:
-.idea/**/mongoSettings.xml
-
-## File-based project format:
-*.iws
-
-## Plugin-specific files:
-
-# IntelliJ
-/out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Ruby plugin and RubyMine
-/.rakeTasks
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-### PhpStorm Patch ###
-# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
-
-# *.iml
-# modules.xml
-# .idea/misc.xml
-# *.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
+/.idea
+/.vscode
+/vendor
+*.log
+.env

Разница между файлами не показана из-за своего большого размера
+ 42 - 0
.travis.yml


+ 32 - 0
LICENSE.txt

@@ -0,0 +1,32 @@
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
+All rights reserved。
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+Apache Licence是著名的非盈利开源组织Apache采用的协议。
+该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
+允许代码修改,再作为开源或商业软件发布。需要满足
+的条件: 
+1. 需要给代码的用户一份Apache Licence ;
+2. 如果你修改了代码,需要在被修改的文件中说明;
+3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
+带有原来代码中的协议,商标,专利声明和其他原来作者规
+定需要包含的说明;
+4. 如果再发布的产品中包含一个Notice文件,则在Notice文
+件中需要带有本协议内容。你可以在Notice中增加自己的
+许可,但不可以表现为对Apache Licence构成更改。 
+具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.

+ 55 - 2
README.md

@@ -1,3 +1,56 @@
-# demo_websocket_tlv
+ThinkPHP 6.0
+===============
 
-基于tlv协议的websocket实现demo
+> 运行环境要求PHP7.1+,兼容PHP8.0。
+
+[官方应用服务市场](https://market.topthink.com) | [`ThinkAPI`——官方统一API服务](https://docs.topthink.com/think-api)
+
+ThinkPHPV6.0版本由[亿速云](https://www.yisu.com/)独家赞助发布。
+
+## 主要新特性
+
+* 采用`PHP7`强类型(严格模式)
+* 支持更多的`PSR`规范
+* 原生多应用支持
+* 更强大和易用的查询
+* 全新的事件系统
+* 模型事件和数据库事件统一纳入事件系统
+* 模板引擎分离出核心
+* 内部功能中间件化
+* SESSION/Cookie机制改进
+* 对Swoole以及协程支持改进
+* 对IDE更加友好
+* 统一和精简大量用法
+
+## 安装
+
+~~~
+composer create-project topthink/think tp 6.0.*
+~~~
+
+如果需要更新框架使用
+~~~
+composer update topthink/framework
+~~~
+
+## 文档
+
+[完全开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
+
+## 参与开发
+
+请参阅 [ThinkPHP 核心框架包](https://github.com/top-think/framework)。
+
+## 版权信息
+
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
+
+本项目包含的第三方源码和二进制文件之版权信息另行标注。
+
+版权所有Copyright © 2006-2020 by ThinkPHP (http://thinkphp.cn)
+
+All rights reserved。
+
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
+
+更多细节参阅 [LICENSE.txt](LICENSE.txt)

+ 1 - 0
app/.htaccess

@@ -0,0 +1 @@
+deny from all

+ 22 - 0
app/AppService.php

@@ -0,0 +1,22 @@
+<?php
+declare (strict_types = 1);
+
+namespace app;
+
+use think\Service;
+
+/**
+ * 应用服务类
+ */
+class AppService extends Service
+{
+    public function register()
+    {
+        // 服务注册
+    }
+
+    public function boot()
+    {
+        // 服务启动
+    }
+}

+ 94 - 0
app/BaseController.php

@@ -0,0 +1,94 @@
+<?php
+declare (strict_types = 1);
+
+namespace app;
+
+use think\App;
+use think\exception\ValidateException;
+use think\Validate;
+
+/**
+ * 控制器基础类
+ */
+abstract class BaseController
+{
+    /**
+     * Request实例
+     * @var \think\Request
+     */
+    protected $request;
+
+    /**
+     * 应用实例
+     * @var \think\App
+     */
+    protected $app;
+
+    /**
+     * 是否批量验证
+     * @var bool
+     */
+    protected $batchValidate = false;
+
+    /**
+     * 控制器中间件
+     * @var array
+     */
+    protected $middleware = [];
+
+    /**
+     * 构造方法
+     * @access public
+     * @param  App  $app  应用对象
+     */
+    public function __construct(App $app)
+    {
+        $this->app     = $app;
+        $this->request = $this->app->request;
+
+        // 控制器初始化
+        $this->initialize();
+    }
+
+    // 初始化
+    protected function initialize()
+    {}
+
+    /**
+     * 验证数据
+     * @access protected
+     * @param  array        $data     数据
+     * @param  string|array $validate 验证器名或者验证规则数组
+     * @param  array        $message  提示信息
+     * @param  bool         $batch    是否批量验证
+     * @return array|string|true
+     * @throws ValidateException
+     */
+    protected function validate(array $data, $validate, array $message = [], bool $batch = false)
+    {
+        if (is_array($validate)) {
+            $v = new Validate();
+            $v->rule($validate);
+        } else {
+            if (strpos($validate, '.')) {
+                // 支持场景
+                [$validate, $scene] = explode('.', $validate);
+            }
+            $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
+            $v     = new $class();
+            if (!empty($scene)) {
+                $v->scene($scene);
+            }
+        }
+
+        $v->message($message);
+
+        // 是否批量验证
+        if ($batch || $this->batchValidate) {
+            $v->batch(true);
+        }
+
+        return $v->failException(true)->check($data);
+    }
+
+}

+ 58 - 0
app/ExceptionHandle.php

@@ -0,0 +1,58 @@
+<?php
+namespace app;
+
+use think\db\exception\DataNotFoundException;
+use think\db\exception\ModelNotFoundException;
+use think\exception\Handle;
+use think\exception\HttpException;
+use think\exception\HttpResponseException;
+use think\exception\ValidateException;
+use think\Response;
+use Throwable;
+
+/**
+ * 应用异常处理类
+ */
+class ExceptionHandle extends Handle
+{
+    /**
+     * 不需要记录信息(日志)的异常类列表
+     * @var array
+     */
+    protected $ignoreReport = [
+        HttpException::class,
+        HttpResponseException::class,
+        ModelNotFoundException::class,
+        DataNotFoundException::class,
+        ValidateException::class,
+    ];
+
+    /**
+     * 记录异常信息(包括日志或者其它方式记录)
+     *
+     * @access public
+     * @param  Throwable $exception
+     * @return void
+     */
+    public function report(Throwable $exception): void
+    {
+        // 使用内置的方式记录异常日志
+        parent::report($exception);
+    }
+
+    /**
+     * Render an exception into an HTTP response.
+     *
+     * @access public
+     * @param \think\Request   $request
+     * @param Throwable $e
+     * @return Response
+     */
+    public function render($request, Throwable $e): Response
+    {
+        // 添加自定义异常处理机制
+
+        // 其他错误交给系统处理
+        return parent::render($request, $e);
+    }
+}

+ 8 - 0
app/Request.php

@@ -0,0 +1,8 @@
+<?php
+namespace app;
+
+// 应用请求对象类
+class Request extends \think\Request
+{
+
+}

+ 51 - 0
app/command/Base.php

@@ -0,0 +1,51 @@
+<?php
+
+
+namespace app\command;
+
+
+use think\console\Input;
+use think\console\Output;
+use think\facade\Log;
+
+/**
+ * 命令行基类,提供基本功能,继承的子类重写main方法即可
+ * Class Base
+ * @package app\command
+ */
+class Base extends \think\console\Command
+{
+    protected $input; //输入变量
+    protected $output;//输出引用
+
+    /**
+     * 输出方法
+     * @param $obj
+     * @param string $type
+     */
+    protected function writeln($obj,$type="info"){
+        $msg=print_r($obj,true);
+        Log::record($msg,$type);
+        $this->output->writeln("[".$type."]".$msg);
+    }
+
+    /**
+     * 命令行核心方法,不要重写
+     * @param Input $input
+     * @param Output $output
+     * @return int|void|null
+     */
+    protected function execute(Input $input, Output $output)
+    {
+        $this->input=$input;
+        $this->output=$output;
+        $this->main();
+    }
+
+    /**
+     * 命令行主程序,继承后重写此方法,将业务写在此方法中
+     */
+    protected function main(){
+
+    }
+}

+ 33 - 0
app/command/WebSocketClient.php

@@ -0,0 +1,33 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;
+
+class WebSocketClient extends Base
+{
+    protected function configure()
+    {
+        // 指令配置
+        $this->setName('webSocketClient')
+            ->setDescription('the webSocketClient command');
+    }
+
+    protected function main()
+    {
+        parent::main(); // TODO: Change the autogenerated stub
+        $this->writeln("webSocketServer","info");
+        $work=new \app\common\workman\WebSocketClient();
+        $work->start();
+        /*while (true){
+
+        }*/
+        $this->writeln("end","info");
+        //启动websocket服务
+    }
+}

+ 35 - 0
app/command/WebSocketServer.php

@@ -0,0 +1,35 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;
+
+class WebSocketServer extends Base
+{
+    protected function configure()
+    {
+        // 指令配置
+        $this->setName('webSocketServer')
+            ->setDescription('the webSocketServer command');
+    }
+
+    protected function main()
+    {
+        parent::main(); // TODO: Change the autogenerated stub
+        $this->writeln("webSocketServer","info");
+        $work=new \app\common\workman\WebSocketServer();
+        $work->start();
+        /*while (true){
+
+        }*/
+        $this->writeln("end","info");
+        //启动websocket服务
+    }
+
+
+}

+ 2 - 0
app/common.php

@@ -0,0 +1,2 @@
+<?php
+// 应用公共文件

+ 2 - 0
app/common/common.php

@@ -0,0 +1,2 @@
+<?php
+// 这是系统自动生成的公共文件

+ 12 - 0
app/common/controller/Index.php

@@ -0,0 +1,12 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\common\controller;
+
+class Index
+{
+    public function index()
+    {
+        return '您好!这是一个[common]示例应用';
+    }
+}

+ 5 - 0
app/common/event.php

@@ -0,0 +1,5 @@
+<?php
+// 这是系统自动生成的event定义文件
+return [
+
+];

+ 5 - 0
app/common/middleware.php

@@ -0,0 +1,5 @@
+<?php
+// 这是系统自动生成的middleware定义文件
+return [
+
+];

+ 123 - 0
app/common/workman/Tlv.php

@@ -0,0 +1,123 @@
+<?php
+
+
+namespace app\common\workman;
+
+
+class Tlv
+{
+
+    /**
+     *
+     * TLV包解析类
+     *
+     */
+
+    private $buffer;
+    private $t_len = 4;                //T长度
+    private $l_len = 4;                //L长度
+    private $buf_len = 0;          //字节流长度
+    private $buf_array = array();
+
+    /**
+     * 构造函数
+     */
+    function __construct()
+    {
+    }
+
+    /**
+     * 解析数据
+     *
+     * @param byte $buffer 二进制流数据
+     * @param  $IsArray
+     * @return array
+     */
+    public function Read($buffer, $IsArray = false)
+    {
+        $this->buffer = $buffer;
+        $this->buf_len = strlen($this->buffer);
+
+        //清空数组
+        if (isset($this->buf_array)) {
+            unset($this->buf_array);
+            $this->buf_array = array();
+        }
+
+        $i = 0;
+        while ($i < $this->buf_len) {
+            //获取TGA
+            $t = $this->getLength($i, $this->t_len);
+            if ($this->toHex($t) == "0xffffffff") break;
+            $i += $this->t_len;
+            //获取Length
+            $l = $this->getLength($i, $this->l_len);
+            $i += $this->l_len;
+            //获取Value
+            $v = substr($this->buffer, $i, $l);
+            $i += $l;
+
+            if ($IsArray) {
+                $this->buf_array[$this->toHex($t)] = array($this->toHex($t), $l, $v);
+            } else {
+                array_push($this->buf_array, array($this->toHex($t), $l, $v));
+            }
+        }
+        return $this->buf_array;
+    }
+
+    //将数组转换二进制数据
+    public function Write($arrdata)
+    {
+        $msg = '';
+        for ($i = 0; $i < count($arrdata); $i++) {
+            $msg .= $this->Pack("N*", $arrdata[$i][0]);
+            $msg .= $this->Pack("N*", $arrdata[$i][1]);
+            $msg .= $arrdata[$i][2];
+        }
+        return $msg;
+    }
+
+    //获取值
+    protected function getValue($key)
+    {
+        return $this->buf_array[$key][2];
+    }
+
+    //转换成十六进制
+    protected function toHex($value)
+    {
+        return "0x" . dechex($value);
+    }
+
+    //压包
+    protected function Pack($format, $data)
+    {
+        return pack($format, $data);
+    }
+
+    //解包
+    protected function Unpack($format, $data)
+    {
+//        var_dump($format);
+//        var_dump($data);
+        $ret = unpack($format, $data);
+//        var_dump($ret);
+        return $ret[1];
+    }
+
+    protected function getLength($start, $len)
+    {
+        return $this->Unpack('N*', substr($this->buffer, $start, $len));
+    }
+
+    //清楚所有数据
+    protected function Clear()
+    {
+        if (isset($this->buffer)) {
+            unset($this->buffer);
+        }
+        $this->buf_len = 0;
+    }
+
+}

+ 70 - 0
app/common/workman/WebSocketClient.php

@@ -0,0 +1,70 @@
+<?php
+
+
+namespace app\common\workman;
+
+
+use Workerman\Connection\AsyncTcpConnection;
+use Workerman\Worker;
+
+/**
+ * websocket客户端
+ * Class WebSocketClient
+ * @package app\common\workman
+ */
+class WebSocketClient
+{
+    protected $worker;//websocket实例
+    /**
+     * 构造方法
+     * WebSocketServer constructor.
+     */
+    public function __construct()
+    {
+
+    }
+
+    /**
+     * 启动
+     */
+    public function start(){
+
+
+
+        $this->worker = new Worker();
+
+        $this->run();
+    }
+
+    /**
+     * 业务方法,业务写在这里
+     */
+    private function run(){
+        $this->worker->onWorkerStart = function ($worker) {
+            $host = "ws://127.0.0.1:23456";//定义协议和端口,后续可以放到配置中
+            $con = new AsyncTcpConnection($host);
+
+            $con->onConnect = function($con) {
+                $tlv=new Tlv();
+                $tag = 0x01;
+                $value = 'Hello i am client';
+                $length = strlen( $value );
+                $data = array(
+                    array($tag, $length,$value),
+                    array($tag, $length,$value)
+                );
+//组包
+                $data = $tlv->Write($data);
+                $con->send($data);
+            };
+
+            $con->onMessage = function($con, $data) {
+                echo $data;
+                //$con->send('hello,i am client');
+            };
+
+            $con->connect();
+        };
+        Worker::runAll();
+    }
+}

+ 58 - 0
app/common/workman/WebSocketServer.php

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace app\common\workman;
+
+
+use Workerman\Worker;
+
+/**
+ * websocket服务器
+ * Class WebSocketServer
+ * @package app\common\workman
+ */
+class WebSocketServer
+{
+    protected $worker;//websocket实例
+
+    /**
+     * 构造方法
+     * WebSocketServer constructor.
+     */
+    public function __construct()
+    {
+
+    }
+
+    /**
+     * 启动
+     */
+    public function start()
+    {
+        $host="websocket://0.0.0.0:23456";//定义协议和端口,后续可以放到配置中
+        $this->worker=new Worker($host);
+        $this->worker->count=4;
+        $this->run();
+    }
+
+    /**
+     * 业务方法,业务写在这里
+     */
+    private function run()
+    {
+        $this->worker->onMessage = function ($connection, $data) {
+            // 向浏览器发送hello world
+            $connection->send('hello world,i am server');
+           /* echo date("Y-m-d H:i:s:");
+            echo $data;
+            echo "\n";*/
+            $tlv=new Tlv();
+            $result=$tlv->Read($data);
+            echo "[tlv]".date("Y-m-d H:i:s:");
+            print_r( $result);
+            echo "\n";
+        };
+        Worker::runAll();
+    }
+
+}

Разница между файлами не показана из-за своего большого размера
+ 17 - 0
app/controller/Index.php


+ 17 - 0
app/event.php

@@ -0,0 +1,17 @@
+<?php
+// 事件定义文件
+return [
+    'bind'      => [
+    ],
+
+    'listen'    => [
+        'AppInit'  => [],
+        'HttpRun'  => [],
+        'HttpEnd'  => [],
+        'LogLevel' => [],
+        'LogWrite' => [],
+    ],
+
+    'subscribe' => [
+    ],
+];

+ 10 - 0
app/middleware.php

@@ -0,0 +1,10 @@
+<?php
+// 全局中间件定义文件
+return [
+    // 全局请求缓存
+    // \think\middleware\CheckRequestCache::class,
+    // 多语言加载
+    // \think\middleware\LoadLangPack::class,
+    // Session初始化
+    // \think\middleware\SessionInit::class
+];

+ 9 - 0
app/provider.php

@@ -0,0 +1,9 @@
+<?php
+use app\ExceptionHandle;
+use app\Request;
+
+// 容器Provider定义文件
+return [
+    'think\Request'          => Request::class,
+    'think\exception\Handle' => ExceptionHandle::class,
+];

+ 9 - 0
app/service.php

@@ -0,0 +1,9 @@
+<?php
+
+use app\AppService;
+
+// 系统服务定义文件
+// 服务在完成全局初始化之后执行
+return [
+    AppService::class,
+];

+ 2 - 0
app/websocket/common.php

@@ -0,0 +1,2 @@
+<?php
+// 这是系统自动生成的公共文件

+ 12 - 0
app/websocket/controller/Index.php

@@ -0,0 +1,12 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\websocket\controller;
+
+class Index
+{
+    public function index()
+    {
+        return '您好!这是一个[websocket]示例应用';
+    }
+}

+ 5 - 0
app/websocket/event.php

@@ -0,0 +1,5 @@
+<?php
+// 这是系统自动生成的event定义文件
+return [
+
+];

+ 5 - 0
app/websocket/middleware.php

@@ -0,0 +1,5 @@
+<?php
+// 这是系统自动生成的middleware定义文件
+return [
+
+];

+ 50 - 0
composer.json

@@ -0,0 +1,50 @@
+{
+    "name": "topthink/think",
+    "description": "the new thinkphp framework",
+    "type": "project",
+    "keywords": [
+        "framework",
+        "thinkphp",
+        "ORM"
+    ],
+    "homepage": "http://thinkphp.cn/",
+    "license": "Apache-2.0",
+    "authors": [
+        {
+            "name": "liu21st",
+            "email": "liu21st@gmail.com"
+        },
+        {
+            "name": "yunwuxin",
+            "email": "448901948@qq.com"
+        }        
+    ],
+    "require": {
+        "php": ">=7.0",
+        "topthink/framework": "^6.0.0",
+        "topthink/think-orm": "^2.0",
+        "topthink/think-multi-app": "^1.0",
+        "workerman/workerman": "^4.0"
+    },
+    "require-dev": {
+        "symfony/var-dumper": "^4.2",
+        "topthink/think-trace":"^1.0"
+    },
+    "autoload": {
+        "psr-4": {
+            "app\\": "app"
+        },
+        "psr-0": {
+            "": "extend/"
+        }
+    },
+    "config": {
+        "preferred-install": "dist"
+    },
+    "scripts": {
+        "post-autoload-dump": [
+            "@php think service:discover",
+            "@php think vendor:publish"
+        ]
+    }
+}

Разница между файлами не показана из-за своего большого размера
+ 1167 - 0
composer.lock


+ 32 - 0
config/app.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | 应用设置
+// +----------------------------------------------------------------------
+
+return [
+    // 应用地址
+    'app_host'         => env('app.host', ''),
+    // 应用的命名空间
+    'app_namespace'    => '',
+    // 是否启用路由
+    'with_route'       => true,
+    // 默认应用
+    'default_app'      => 'index',
+    // 默认时区
+    'default_timezone' => 'Asia/Shanghai',
+
+    // 应用映射(自动多应用模式有效)
+    'app_map'          => [],
+    // 域名绑定(自动多应用模式有效)
+    'domain_bind'      => [],
+    // 禁止URL访问的应用列表(自动多应用模式有效)
+    'deny_app_list'    => [],
+
+    // 异常页面的模板文件
+    'exception_tmpl'   => app()->getThinkPath() . 'tpl/think_exception.tpl',
+
+    // 错误显示信息,非调试模式有效
+    'error_message'    => '页面错误!请稍后再试~',
+    // 显示错误信息
+    'show_error_msg'   => false,
+];

+ 29 - 0
config/cache.php

@@ -0,0 +1,29 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | 缓存设置
+// +----------------------------------------------------------------------
+
+return [
+    // 默认缓存驱动
+    'default' => env('cache.driver', 'file'),
+
+    // 缓存连接方式配置
+    'stores'  => [
+        'file' => [
+            // 驱动方式
+            'type'       => 'File',
+            // 缓存保存目录
+            'path'       => '',
+            // 缓存前缀
+            'prefix'     => '',
+            // 缓存有效期 0表示永久缓存
+            'expire'     => 0,
+            // 缓存标签前缀
+            'tag_prefix' => 'tag:',
+            // 序列化机制 例如 ['serialize', 'unserialize']
+            'serialize'  => [],
+        ],
+        // 更多的缓存连接
+    ],
+];

+ 11 - 0
config/console.php

@@ -0,0 +1,11 @@
+<?php
+// +----------------------------------------------------------------------
+// | 控制台配置
+// +----------------------------------------------------------------------
+return [
+    // 指令定义
+    'commands' => [
+        'webSocketServer'=>'app\command\WebSocketServer',
+        'webSocketClient'=>'app\command\WebSocketClient',
+    ],
+];

+ 20 - 0
config/cookie.php

@@ -0,0 +1,20 @@
+<?php
+// +----------------------------------------------------------------------
+// | Cookie设置
+// +----------------------------------------------------------------------
+return [
+    // cookie 保存时间
+    'expire'    => 0,
+    // cookie 保存路径
+    'path'      => '/',
+    // cookie 有效域名
+    'domain'    => '',
+    //  cookie 启用安全传输
+    'secure'    => false,
+    // httponly设置
+    'httponly'  => false,
+    // 是否使用 setcookie
+    'setcookie' => true,
+    // samesite 设置,支持 'strict' 'lax'
+    'samesite'  => '',
+];

+ 60 - 0
config/database.php

@@ -0,0 +1,60 @@
+<?php
+
+return [
+    // 默认使用的数据库连接配置
+    'default'         => env('database.driver', 'mysql'),
+
+    // 自定义时间查询规则
+    'time_query_rule' => [],
+
+    // 自动写入时间戳字段
+    // true为自动识别类型 false关闭
+    // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
+    'auto_timestamp'  => true,
+
+    // 时间字段取出后的默认时间格式
+    'datetime_format' => 'Y-m-d H:i:s',
+
+    // 数据库连接配置信息
+    'connections'     => [
+        'mysql' => [
+            // 数据库类型
+            'type'            => env('database.type', 'mysql'),
+            // 服务器地址
+            'hostname'        => env('database.hostname', '127.0.0.1'),
+            // 数据库名
+            'database'        => env('database.database', ''),
+            // 用户名
+            'username'        => env('database.username', 'root'),
+            // 密码
+            'password'        => env('database.password', ''),
+            // 端口
+            'hostport'        => env('database.hostport', '3306'),
+            // 数据库连接参数
+            'params'          => [],
+            // 数据库编码默认采用utf8
+            'charset'         => env('database.charset', 'utf8'),
+            // 数据库表前缀
+            'prefix'          => env('database.prefix', ''),
+
+            // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
+            'deploy'          => 0,
+            // 数据库读写是否分离 主从式有效
+            'rw_separate'     => false,
+            // 读写分离后 主服务器数量
+            'master_num'      => 1,
+            // 指定从服务器序号
+            'slave_no'        => '',
+            // 是否严格检查字段是否存在
+            'fields_strict'   => true,
+            // 是否需要断线重连
+            'break_reconnect' => false,
+            // 监听SQL
+            'trigger_sql'     => env('app_debug', true),
+            // 开启字段缓存
+            'fields_cache'    => false,
+        ],
+
+        // 更多的数据库配置信息
+    ],
+];

+ 24 - 0
config/filesystem.php

@@ -0,0 +1,24 @@
+<?php
+
+return [
+    // 默认磁盘
+    'default' => env('filesystem.driver', 'local'),
+    // 磁盘列表
+    'disks'   => [
+        'local'  => [
+            'type' => 'local',
+            'root' => app()->getRuntimePath() . 'storage',
+        ],
+        'public' => [
+            // 磁盘类型
+            'type'       => 'local',
+            // 磁盘路径
+            'root'       => app()->getRootPath() . 'public/storage',
+            // 磁盘路径对应的外部URL路径
+            'url'        => '/storage',
+            // 可见性
+            'visibility' => 'public',
+        ],
+        // 更多的磁盘配置信息
+    ],
+];

+ 27 - 0
config/lang.php

@@ -0,0 +1,27 @@
+<?php
+// +----------------------------------------------------------------------
+// | 多语言设置
+// +----------------------------------------------------------------------
+
+return [
+    // 默认语言
+    'default_lang'    => env('lang.default_lang', 'zh-cn'),
+    // 允许的语言列表
+    'allow_lang_list' => [],
+    // 多语言自动侦测变量名
+    'detect_var'      => 'lang',
+    // 是否使用Cookie记录
+    'use_cookie'      => true,
+    // 多语言cookie变量
+    'cookie_var'      => 'think_lang',
+    // 多语言header变量
+    'header_var'      => 'think-lang',
+    // 扩展语言包
+    'extend_list'     => [],
+    // Accept-Language转义为对应语言包名称
+    'accept_language' => [
+        'zh-hans-cn' => 'zh-cn',
+    ],
+    // 是否支持语言分组
+    'allow_group'     => false,
+];

+ 45 - 0
config/log.php

@@ -0,0 +1,45 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | 日志设置
+// +----------------------------------------------------------------------
+return [
+    // 默认日志记录通道
+    'default'      => env('log.channel', 'file'),
+    // 日志记录级别
+    'level'        => [],
+    // 日志类型记录的通道 ['error'=>'email',...]
+    'type_channel' => [],
+    // 关闭全局日志写入
+    'close'        => false,
+    // 全局日志处理 支持闭包
+    'processor'    => null,
+
+    // 日志通道列表
+    'channels'     => [
+        'file' => [
+            // 日志记录方式
+            'type'           => 'File',
+            // 日志保存目录
+            'path'           => '',
+            // 单文件日志写入
+            'single'         => false,
+            // 独立日志级别
+            'apart_level'    => [],
+            // 最大日志文件数量
+            'max_files'      => 0,
+            // 使用JSON格式记录
+            'json'           => false,
+            // 日志处理
+            'processor'      => null,
+            // 关闭通道日志写入
+            'close'          => false,
+            // 日志输出格式化
+            'format'         => '[%s][%s] %s',
+            // 是否实时写入
+            'realtime_write' => false,
+        ],
+        // 其它日志通道配置
+    ],
+
+];

+ 8 - 0
config/middleware.php

@@ -0,0 +1,8 @@
+<?php
+// 中间件配置
+return [
+    // 别名或分组
+    'alias'    => [],
+    // 优先级设置,此数组中的中间件会按照数组中的顺序优先执行
+    'priority' => [],
+];

+ 45 - 0
config/route.php

@@ -0,0 +1,45 @@
+<?php
+// +----------------------------------------------------------------------
+// | 路由设置
+// +----------------------------------------------------------------------
+
+return [
+    // pathinfo分隔符
+    'pathinfo_depr'         => '/',
+    // URL伪静态后缀
+    'url_html_suffix'       => 'html',
+    // URL普通方式参数 用于自动生成
+    'url_common_param'      => true,
+    // 是否开启路由延迟解析
+    'url_lazy_route'        => false,
+    // 是否强制使用路由
+    'url_route_must'        => false,
+    // 合并路由规则
+    'route_rule_merge'      => false,
+    // 路由是否完全匹配
+    'route_complete_match'  => false,
+    // 访问控制器层名称
+    'controller_layer'      => 'controller',
+    // 空控制器名
+    'empty_controller'      => 'Error',
+    // 是否使用控制器后缀
+    'controller_suffix'     => false,
+    // 默认的路由变量规则
+    'default_route_pattern' => '[\w\.]+',
+    // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
+    'request_cache_key'     => false,
+    // 请求缓存有效期
+    'request_cache_expire'  => null,
+    // 全局请求缓存排除规则
+    'request_cache_except'  => [],
+    // 默认控制器名
+    'default_controller'    => 'Index',
+    // 默认操作名
+    'default_action'        => 'index',
+    // 操作方法后缀
+    'action_suffix'         => '',
+    // 默认JSONP格式返回的处理方法
+    'default_jsonp_handler' => 'jsonpReturn',
+    // 默认JSONP处理方法
+    'var_jsonp_handler'     => 'callback',
+];

+ 19 - 0
config/session.php

@@ -0,0 +1,19 @@
+<?php
+// +----------------------------------------------------------------------
+// | 会话设置
+// +----------------------------------------------------------------------
+
+return [
+    // session name
+    'name'           => 'PHPSESSID',
+    // SESSION_ID的提交变量,解决flash上传跨域
+    'var_session_id' => '',
+    // 驱动方式 支持file cache
+    'type'           => 'file',
+    // 存储连接标识 当type使用cache的时候有效
+    'store'          => null,
+    // 过期时间
+    'expire'         => 1440,
+    // 前缀
+    'prefix'         => '',
+];

+ 10 - 0
config/trace.php

@@ -0,0 +1,10 @@
+<?php
+// +----------------------------------------------------------------------
+// | Trace设置 开启调试模式后有效
+// +----------------------------------------------------------------------
+return [
+    // 内置Html和Console两种方式 支持扩展
+    'type'    => 'Html',
+    // 读取的日志通道名
+    'channel' => '',
+];

+ 25 - 0
config/view.php

@@ -0,0 +1,25 @@
+<?php
+// +----------------------------------------------------------------------
+// | 模板设置
+// +----------------------------------------------------------------------
+
+return [
+    // 模板引擎类型使用Think
+    'type'          => 'Think',
+    // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
+    'auto_rule'     => 1,
+    // 模板目录名
+    'view_dir_name' => 'view',
+    // 模板后缀
+    'view_suffix'   => 'html',
+    // 模板文件名分隔符
+    'view_depr'     => DIRECTORY_SEPARATOR,
+    // 模板引擎普通标签开始标记
+    'tpl_begin'     => '{',
+    // 模板引擎普通标签结束标记
+    'tpl_end'       => '}',
+    // 标签库标签开始标记
+    'taglib_begin'  => '{',
+    // 标签库标签结束标记
+    'taglib_end'    => '}',
+];

+ 2 - 0
extend/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 23 - 0
html/websocket_client/.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 24 - 0
html/websocket_client/README.md

@@ -0,0 +1,24 @@
+# websocket_client
+
+## Project setup
+```
+npm install
+```
+
+### Compiles and hot-reloads for development
+```
+npm run serve
+```
+
+### Compiles and minifies for production
+```
+npm run build
+```
+
+### Lints and fixes files
+```
+npm run lint
+```
+
+### Customize configuration
+See [Configuration Reference](https://cli.vuejs.org/config/).

+ 5 - 0
html/websocket_client/babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/cli-plugin-babel/preset'
+  ]
+}

Разница между файлами не показана из-за своего большого размера
+ 11938 - 0
html/websocket_client/package-lock.json


+ 43 - 0
html/websocket_client/package.json

@@ -0,0 +1,43 @@
+{
+  "name": "websocket_client",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "start": "vue-cli-service serve",
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "core-js": "^3.6.5",
+    "vue": "^2.6.11"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "~4.5.0",
+    "@vue/cli-plugin-eslint": "~4.5.0",
+    "@vue/cli-service": "~4.5.0",
+    "babel-eslint": "^10.1.0",
+    "eslint": "^6.7.2",
+    "eslint-plugin-vue": "^6.2.2",
+    "vue-template-compiler": "^2.6.11"
+  },
+  "eslintConfig": {
+    "root": true,
+    "env": {
+      "node": true
+    },
+    "extends": [
+      "plugin:vue/essential",
+      "eslint:recommended"
+    ],
+    "parserOptions": {
+      "parser": "babel-eslint"
+    },
+    "rules": {}
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions",
+    "not dead"
+  ]
+}

BIN
html/websocket_client/public/favicon.ico


+ 17 - 0
html/websocket_client/public/index.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title><%= htmlWebpackPlugin.options.title %></title>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 29 - 0
html/websocket_client/src/App.vue

@@ -0,0 +1,29 @@
+<template>
+  <div id="app">
+    <img alt="Vue logo" src="./assets/logo.png">
+    <div>this is index</div>
+    <web-socket></web-socket>
+  </div>
+</template>
+
+<script>
+
+import webSocket from "./components/web-socket";
+export default {
+  name: 'App',
+  components:{
+    webSocket
+  }
+}
+</script>
+
+<style>
+#app {
+  font-family: Avenir, Helvetica, Arial, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #2c3e50;
+  margin-top: 60px;
+}
+</style>

BIN
html/websocket_client/src/assets/logo.png


+ 58 - 0
html/websocket_client/src/components/HelloWorld.vue

@@ -0,0 +1,58 @@
+<template>
+  <div class="hello">
+    <h1>{{ msg }}</h1>
+    <p>
+      For a guide and recipes on how to configure / customize this project,<br>
+      check out the
+      <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
+    </p>
+    <h3>Installed CLI Plugins</h3>
+    <ul>
+      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
+      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
+    </ul>
+    <h3>Essential Links</h3>
+    <ul>
+      <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
+      <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
+      <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
+      <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
+      <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
+    </ul>
+    <h3>Ecosystem</h3>
+    <ul>
+      <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
+      <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
+      <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
+      <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
+      <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
+    </ul>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'HelloWorld',
+  props: {
+    msg: String
+  }
+}
+</script>
+
+<!-- Add "scoped" attribute to limit CSS to this component only -->
+<style scoped>
+h3 {
+  margin: 40px 0 0;
+}
+ul {
+  list-style-type: none;
+  padding: 0;
+}
+li {
+  display: inline-block;
+  margin: 0 10px;
+}
+a {
+  color: #42b983;
+}
+</style>

+ 68 - 0
html/websocket_client/src/components/web-socket.vue

@@ -0,0 +1,68 @@
+<template>
+  <section>
+    <div>这是websocket的组件</div>
+    <div>
+      <input type="text" v-model="text">
+      <button @click="sentMessage">发送</button>
+    </div>
+  </section>
+</template>
+
+<script>
+let ws;
+export default {
+  name: "web-socket.vue",
+  data() {
+    return {
+      text: "",//文本
+    }
+
+  },
+  created() {
+    this.webSocketInit();
+  },
+  methods: {
+    combineTlv(text){
+      const buf = Buffer.alloc(8+text.length);
+// 写入TYPE
+      buf.writeIntBE(21, 0, 4);
+// 写入LENGTH
+      buf.writeIntBE(text.length, 4, 4);
+// 写入test
+      buf.write(text, 8, text.length);
+      return buf;
+    },
+    sentMessage() {
+      // buf总长度为4字节TYPE+4字节VALUE长度+test的字节数为12
+
+      ws.send(this.combineTlv(this.text)); //将消息发送到服务端
+    },
+    webSocketInit() {
+      ws = new WebSocket("ws://localhost:23456");
+//申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
+      ws.onopen = function () {
+        //当WebSocket创建成功时,触发onopen事件
+        console.log("open");
+        ws.send(this.combineTlv("hello")); //将消息发送到服务端
+      }
+      ws.onmessage = function (e) {
+        //当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
+        alert(e.data);
+        console.log(e.data);
+      }
+      ws.onclose = function (e) {
+        //当客户端收到服务端发送的关闭连接请求时,触发onclose事件
+        console.log("close", e);
+      }
+      ws.onerror = function (e) {
+        //如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
+        console.log(e);
+      }
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 8 - 0
html/websocket_client/src/main.js

@@ -0,0 +1,8 @@
+import Vue from 'vue'
+import App from './App.vue'
+
+Vue.config.productionTip = false
+
+new Vue({
+  render: h => h(App),
+}).$mount('#app')

+ 8 - 0
public/.htaccess

@@ -0,0 +1,8 @@
+<IfModule mod_rewrite.c>
+  Options +FollowSymlinks -Multiviews
+  RewriteEngine On
+
+  RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_FILENAME} !-f
+  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
+</IfModule>

BIN
public/favicon.ico


+ 24 - 0
public/index.php

@@ -0,0 +1,24 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+
+// [ 应用入口文件 ]
+namespace think;
+
+require __DIR__ . '/../vendor/autoload.php';
+
+// 执行HTTP应用并响应
+$http = (new App())->http;
+
+$response = $http->run();
+
+$response->send();
+
+$http->end($response);

+ 2 - 0
public/robots.txt

@@ -0,0 +1,2 @@
+User-agent: *
+Disallow:

+ 19 - 0
public/router.php

@@ -0,0 +1,19 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+// $Id$
+
+if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) {
+    return false;
+} else {
+    $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php';
+
+    require __DIR__ . "/index.php";
+}

+ 2 - 0
public/static/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 17 - 0
route/app.php

@@ -0,0 +1,17 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +----------------------------------------------------------------------
+// | Author: liu21st <liu21st@gmail.com>
+// +----------------------------------------------------------------------
+use think\facade\Route;
+
+Route::get('think', function () {
+    return 'hello,ThinkPHP6!';
+});
+
+Route::get('hello/:name', 'index/hello');

+ 2 - 0
runtime/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 10 - 0
think

@@ -0,0 +1,10 @@
+#!/usr/bin/env php
+<?php
+namespace think;
+
+// 命令行入口文件
+// 加载基础文件
+require __DIR__ . '/vendor/autoload.php';
+
+// 应用初始化
+(new App())->console->run();

+ 1 - 0
view/README.md

@@ -0,0 +1 @@
+如果不使用模板,可以删除该目录

+ 14 - 0
说明.txt

@@ -0,0 +1,14 @@
+程序说明 :
+websocket服务器用php+workman实现,入口文件在:/command/WebSocketServer.php
+websocket客户端分别用php+workman实现和javascript实现
+php入口文件在:/command/WebSocketServer.php
+javascript版在:/html/websocke_client
+
+服务器启动命令:
+php think webSocketServer
+
+客户端启动命令:
+php think webSocketClient
+
+前端vue启动命令:
+npm start