├── public ├── favicon.ico ├── robots.txt ├── images │ ├── go.png │ ├── php.png │ ├── sw.png │ ├── clear.png │ ├── noimg.png │ ├── face │ │ ├── 0_1.gif │ │ ├── 1_2.gif │ │ ├── 2_3.gif │ │ ├── 3_4.gif │ │ ├── 4_5.gif │ │ ├── 5_6.gif │ │ ├── 6_7.gif │ │ ├── 7_8.gif │ │ ├── 8_睡.gif │ │ ├── 9_9.gif │ │ ├── 10_10.gif │ │ ├── 11_11.gif │ │ ├── 12_12.gif │ │ ├── 13_13.gif │ │ ├── 14_14.gif │ │ ├── 15_15.gif │ │ ├── 16_16.gif │ │ ├── 17_17.gif │ │ ├── 18_18.gif │ │ ├── 19_19.gif │ │ ├── 20_20.gif │ │ ├── 21_21.gif │ │ ├── 22_22.gif │ │ ├── 23_23.gif │ │ ├── 24_24.gif │ │ ├── 25_25.gif │ │ ├── 26_26.gif │ │ ├── 27_27.gif │ │ ├── 28_28.gif │ │ ├── 29_29.gif │ │ ├── 30_30.gif │ │ ├── 31_31.gif │ │ ├── 32_32.gif │ │ ├── 33_33.gif │ │ ├── 34_34.gif │ │ ├── 35_35.gif │ │ ├── 36_36.gif │ │ ├── 37_37.gif │ │ ├── 38_38.gif │ │ ├── 39_39.gif │ │ ├── 40_40.gif │ │ ├── 41_41.gif │ │ ├── 42_42.gif │ │ ├── 43_43.gif │ │ ├── 44_44.gif │ │ ├── 45_45.gif │ │ ├── 46_46.gif │ │ ├── 47_47.gif │ │ ├── 48_48.gif │ │ ├── 49_49.gif │ │ ├── 50_50.gif │ │ ├── 51_51.gif │ │ ├── 52_52.gif │ │ ├── 53_53.gif │ │ ├── 54_54.gif │ │ ├── 55_55.gif │ │ ├── 56_56.gif │ │ ├── 57_57.gif │ │ ├── 58_58.gif │ │ ├── 59_59.gif │ │ ├── 78_78.gif │ │ └── 81_81.gif │ ├── main-bg.png │ ├── avatar │ │ └── f1 │ │ │ ├── f_1.jpg │ │ │ ├── f_2.jpg │ │ │ ├── f_3.jpg │ │ │ ├── f_4.jpg │ │ │ ├── f_5.jpg │ │ │ ├── f_6.jpg │ │ │ ├── f_7.jpg │ │ │ ├── f_8.jpg │ │ │ ├── f_9.jpg │ │ │ ├── f_10.jpg │ │ │ ├── f_11.jpg │ │ │ └── f_12.jpg │ ├── header_logo.png │ └── forkme_right_orange_ff7600.png ├── fonts │ └── iconfont.woff ├── voices │ ├── notify.mp3 │ ├── notify.ogg │ └── notify.wav ├── mix-manifest.json ├── js │ ├── init.js │ ├── functions.js │ ├── xlyjs.js │ ├── face.js │ └── create.div.js ├── .htaccess ├── web.config ├── index.php └── svg │ ├── 404.svg │ ├── 503.svg │ └── 403.svg ├── storage ├── laravels.pid ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── database ├── .gitignore ├── seeds │ └── DatabaseSeeder.php ├── migrations │ ├── 2014_10_12_100000_create_password_resets_table.php │ └── 2014_10_12_000000_create_users_table.php └── factories │ └── UserFactory.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── resources ├── sass │ ├── app.scss │ └── _variables.scss ├── lang │ └── en │ │ ├── pagination.php │ │ ├── auth.php │ │ ├── passwords.php │ │ └── validation.php ├── js │ ├── components │ │ └── ExampleComponent.vue │ ├── app.js │ └── bootstrap.js └── views │ └── index.blade.php ├── .gitattributes ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── Feature │ └── ExampleTest.php └── CreatesApplication.php ├── .gitignore ├── .editorconfig ├── app ├── Http │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ ├── Authenticate.php │ │ ├── VerifyCsrfToken.php │ │ └── RedirectIfAuthenticated.php │ ├── Controllers │ │ ├── Controller.php │ │ └── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── ResetPasswordController.php │ │ │ ├── VerificationController.php │ │ │ └── RegisterController.php │ └── Kernel.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── User.php ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── ChatTask │ ├── ServerChanTask.php │ └── ChatTask.php └── Services │ ├── WebSocketService.php │ ├── ChatUsersService.php │ └── ChatService.php ├── config ├── serverchan.php ├── view.php ├── services.php ├── hashing.php ├── broadcasting.php ├── filesystems.php ├── logging.php ├── queue.php ├── cache.php ├── auth.php ├── mail.php ├── database.php ├── laravels.php ├── chat.php ├── session.php └── app.php ├── routes ├── api.php ├── web.php ├── channels.php └── console.php ├── webpack.mix.js ├── server.php ├── .env.example ├── package.json ├── phpunit.xml ├── composer.json ├── artisan ├── Dockerfile └── readme.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/laravels.pid: -------------------------------------------------------------------------------- 1 | 2388 -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /public/images/go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/go.png -------------------------------------------------------------------------------- /public/images/php.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/php.png -------------------------------------------------------------------------------- /public/images/sw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/sw.png -------------------------------------------------------------------------------- /resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | 2 | // webim css 3 | @import "style.css"; 4 | @import "shake.css"; -------------------------------------------------------------------------------- /public/images/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/clear.png -------------------------------------------------------------------------------- /public/images/noimg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/noimg.png -------------------------------------------------------------------------------- /public/fonts/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/fonts/iconfont.woff -------------------------------------------------------------------------------- /public/images/face/0_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/0_1.gif -------------------------------------------------------------------------------- /public/images/face/1_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/1_2.gif -------------------------------------------------------------------------------- /public/images/face/2_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/2_3.gif -------------------------------------------------------------------------------- /public/images/face/3_4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/3_4.gif -------------------------------------------------------------------------------- /public/images/face/4_5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/4_5.gif -------------------------------------------------------------------------------- /public/images/face/5_6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/5_6.gif -------------------------------------------------------------------------------- /public/images/face/6_7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/6_7.gif -------------------------------------------------------------------------------- /public/images/face/7_8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/7_8.gif -------------------------------------------------------------------------------- /public/images/face/8_睡.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/8_睡.gif -------------------------------------------------------------------------------- /public/images/face/9_9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/9_9.gif -------------------------------------------------------------------------------- /public/images/main-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/main-bg.png -------------------------------------------------------------------------------- /public/voices/notify.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/voices/notify.mp3 -------------------------------------------------------------------------------- /public/voices/notify.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/voices/notify.ogg -------------------------------------------------------------------------------- /public/voices/notify.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/voices/notify.wav -------------------------------------------------------------------------------- /public/images/face/10_10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/10_10.gif -------------------------------------------------------------------------------- /public/images/face/11_11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/11_11.gif -------------------------------------------------------------------------------- /public/images/face/12_12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/12_12.gif -------------------------------------------------------------------------------- /public/images/face/13_13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/13_13.gif -------------------------------------------------------------------------------- /public/images/face/14_14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/14_14.gif -------------------------------------------------------------------------------- /public/images/face/15_15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/15_15.gif -------------------------------------------------------------------------------- /public/images/face/16_16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/16_16.gif -------------------------------------------------------------------------------- /public/images/face/17_17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/17_17.gif -------------------------------------------------------------------------------- /public/images/face/18_18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/18_18.gif -------------------------------------------------------------------------------- /public/images/face/19_19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/19_19.gif -------------------------------------------------------------------------------- /public/images/face/20_20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/20_20.gif -------------------------------------------------------------------------------- /public/images/face/21_21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/21_21.gif -------------------------------------------------------------------------------- /public/images/face/22_22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/22_22.gif -------------------------------------------------------------------------------- /public/images/face/23_23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/23_23.gif -------------------------------------------------------------------------------- /public/images/face/24_24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/24_24.gif -------------------------------------------------------------------------------- /public/images/face/25_25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/25_25.gif -------------------------------------------------------------------------------- /public/images/face/26_26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/26_26.gif -------------------------------------------------------------------------------- /public/images/face/27_27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/27_27.gif -------------------------------------------------------------------------------- /public/images/face/28_28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/28_28.gif -------------------------------------------------------------------------------- /public/images/face/29_29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/29_29.gif -------------------------------------------------------------------------------- /public/images/face/30_30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/30_30.gif -------------------------------------------------------------------------------- /public/images/face/31_31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/31_31.gif -------------------------------------------------------------------------------- /public/images/face/32_32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/32_32.gif -------------------------------------------------------------------------------- /public/images/face/33_33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/33_33.gif -------------------------------------------------------------------------------- /public/images/face/34_34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/34_34.gif -------------------------------------------------------------------------------- /public/images/face/35_35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/35_35.gif -------------------------------------------------------------------------------- /public/images/face/36_36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/36_36.gif -------------------------------------------------------------------------------- /public/images/face/37_37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/37_37.gif -------------------------------------------------------------------------------- /public/images/face/38_38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/38_38.gif -------------------------------------------------------------------------------- /public/images/face/39_39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/39_39.gif -------------------------------------------------------------------------------- /public/images/face/40_40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/40_40.gif -------------------------------------------------------------------------------- /public/images/face/41_41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/41_41.gif -------------------------------------------------------------------------------- /public/images/face/42_42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/42_42.gif -------------------------------------------------------------------------------- /public/images/face/43_43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/43_43.gif -------------------------------------------------------------------------------- /public/images/face/44_44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/44_44.gif -------------------------------------------------------------------------------- /public/images/face/45_45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/45_45.gif -------------------------------------------------------------------------------- /public/images/face/46_46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/46_46.gif -------------------------------------------------------------------------------- /public/images/face/47_47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/47_47.gif -------------------------------------------------------------------------------- /public/images/face/48_48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/48_48.gif -------------------------------------------------------------------------------- /public/images/face/49_49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/49_49.gif -------------------------------------------------------------------------------- /public/images/face/50_50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/50_50.gif -------------------------------------------------------------------------------- /public/images/face/51_51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/51_51.gif -------------------------------------------------------------------------------- /public/images/face/52_52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/52_52.gif -------------------------------------------------------------------------------- /public/images/face/53_53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/53_53.gif -------------------------------------------------------------------------------- /public/images/face/54_54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/54_54.gif -------------------------------------------------------------------------------- /public/images/face/55_55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/55_55.gif -------------------------------------------------------------------------------- /public/images/face/56_56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/56_56.gif -------------------------------------------------------------------------------- /public/images/face/57_57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/57_57.gif -------------------------------------------------------------------------------- /public/images/face/58_58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/58_58.gif -------------------------------------------------------------------------------- /public/images/face/59_59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/59_59.gif -------------------------------------------------------------------------------- /public/images/face/78_78.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/78_78.gif -------------------------------------------------------------------------------- /public/images/face/81_81.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/face/81_81.gif -------------------------------------------------------------------------------- /public/images/avatar/f1/f_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_1.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_2.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_3.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_4.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_5.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_6.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_7.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_8.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_9.jpg -------------------------------------------------------------------------------- /public/images/header_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/header_logo.png -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } 5 | -------------------------------------------------------------------------------- /public/images/avatar/f1/f_10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_10.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_11.jpg -------------------------------------------------------------------------------- /public/images/avatar/f1/f_12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/avatar/f1/f_12.jpg -------------------------------------------------------------------------------- /public/js/init.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | 'domain' : "http://192.168.10.10:9090", 3 | 'wsserver' : "ws://192.168.10.10:9090", 4 | } -------------------------------------------------------------------------------- /public/images/forkme_right_orange_ff7600.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shisiying/webim/HEAD/public/images/forkme_right_orange_ff7600.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /config/serverchan.php: -------------------------------------------------------------------------------- 1 | 'SCU17044T7eafa406fe38e6d908e392c1d02929c15b4c4233d17f5', 10 | 'a'=>'6739-83848e2aa45a74b30aca15d71ec5e961', //sw群组 11 | 'b'=>'6741-7c0b0355d0485e7e2e86cc6edcdbc7bd',//php群组 12 | 'c'=>'6740-023ed3224f89c6e3d0e4b268a762622a'//go群组 13 | ]; -------------------------------------------------------------------------------- /resources/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f8fafc; 4 | 5 | // Typography 6 | $font-family-sans-serif: "Nunito", sans-serif; 7 | $font-size-base: 0.9rem; 8 | $line-height-base: 1.6; 9 | 10 | // Colors 11 | $blue: #3490dc; 12 | $indigo: #6574cd; 13 | $purple: #9561e2; 14 | $pink: #f66D9b; 15 | $red: #e3342f; 16 | $orange: #f6993f; 17 | $yellow: #ffed4a; 18 | $green: #38c172; 19 | $teal: #4dc0b5; 20 | $cyan: #6cb2eb; 21 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 |
Example Component
7 | 8 |
9 | I'm an example component. 10 |
11 |
12 |
13 |
14 |
15 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=homestead 13 | DB_USERNAME=homestead 14 | DB_PASSWORD=secret 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | PUSHER_APP_ID= 34 | PUSHER_APP_KEY= 35 | PUSHER_APP_SECRET= 36 | PUSHER_APP_CLUSTER=mt1 37 | 38 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 39 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 40 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker $faker) { 17 | return [ 18 | 'name' => $faker->name, 19 | 'email' => $faker->unique()->safeEmail, 20 | 'email_verified_at' => now(), 21 | 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": " NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "npm run development -- --watch", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": " NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": " NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.18", 14 | "bootstrap": "^4.0.0", 15 | "jquery": "^3.2", 16 | "laravel-mix": "^2.0", 17 | "lodash": "^4.17.5", 18 | "popper.js": "^1.12", 19 | "vue": "^2.5.17" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | ./tests/Feature 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerificationController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'ses' => [ 24 | 'key' => env('SES_KEY'), 25 | 'secret' => env('SES_SECRET'), 26 | 'region' => env('SES_REGION', 'us-east-1'), 27 | ], 28 | 29 | 'sparkpost' => [ 30 | 'secret' => env('SPARKPOST_SECRET'), 31 | ], 32 | 33 | 'stripe' => [ 34 | 'model' => App\User::class, 35 | 'key' => env('STRIPE_KEY'), 36 | 'secret' => env('STRIPE_SECRET'), 37 | 'webhook' => [ 38 | 'secret' => env('STRIPE_WEBHOOK_SECRET'), 39 | 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300), 40 | ], 41 | ], 42 | 43 | ]; 44 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | require('./init'); 10 | require('./jquery.min'); 11 | require('./face'); 12 | require('./create.div'); 13 | require('./chat.script'); 14 | require('./functions'); 15 | require('./xlyjs'); 16 | window.Vue = require('vue'); 17 | 18 | /** 19 | * The following block of code may be used to automatically register your 20 | * Vue components. It will recursively scan this directory for the Vue 21 | * components and automatically register them with their "basename". 22 | * 23 | * Eg. ./components/ExampleComponent.vue -> 24 | */ 25 | 26 | Vue.component('example-component', require('./components/ExampleComponent.vue')); 27 | 28 | // const files = require.context('./', true, /\.vue$/i) 29 | 30 | // files.keys().map(key => { 31 | // return Vue.component(_.last(key.split('/')).split('.')[0], files(key)) 32 | // }) 33 | 34 | /** 35 | * Next, we will create a fresh Vue application instance and attach it to 36 | * the page. Then, you may begin adding components to this application 37 | * or customize the JavaScript scaffolding to fit your unique needs. 38 | */ 39 | 40 | const app = new Vue({ 41 | el: '#app' 42 | }); 43 | -------------------------------------------------------------------------------- /public/js/functions.js: -------------------------------------------------------------------------------- 1 | var carrousel = $( ".carrousel" ); 2 | function preview(obj){ 3 | var src = $(obj).attr("src"); 4 | carrousel.find("img").attr( "src", src ); 5 | carrousel.fadeIn( 200 ); 6 | } 7 | 8 | $( ".carrousel" ).click( function(e){ 9 | carrousel.find( "img" ).attr( "src", '' ); 10 | carrousel.fadeOut( 200 ); 11 | } ); 12 | 13 | function upload(){ 14 | var upload = config.domain+"/upload_imgs";//远程上传接口 15 | var callbackurl = '';//回调url 16 | $.app.method.upload(upload,callbackurl,function(data){ 17 | console.log(data); 18 | if(data.msg && (typeof(data.msg) == 'string' || typeof(data.msg.url) == 'string')){ 19 | var url = (typeof(data.msg) == 'string') ? data.msg : data.msg.url; 20 | chat.data.type = 2; 21 | var json = {"type": chat.data.type,"name": chat.data.name,"avatar": chat.data.avatar,"message": url,"c":'img','roomid':chat.data.crd}; 22 | chat.wsSend(JSON.stringify(json)); 23 | //$(".re").attr('src',data.msg.url); 24 | }else{ 25 | var tip = data.err ? data.err : '上传失败'; 26 | $.app.method.tip('提示信息', tip, 'error'); 27 | } 28 | },function(filename){ 29 | if(!filename.match(/\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/i)){ 30 | $.app.method.tip('上传文件后缀不允许'); 31 | return false; 32 | } 33 | return true; 34 | }); 35 | } 36 | function getJsonLength(jsonData){ 37 | var jsonLength = 0; 38 | for(var item in jsonData){ 39 | if(jsonData.hasOwnProperty(item)){ 40 | jsonLength++; 41 | } 42 | 43 | } 44 | return jsonLength; 45 | } 46 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'encrypted' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": "^7.1.3", 9 | "fideloper/proxy": "^4.0", 10 | "hhxsv5/laravel-s": "~3.0", 11 | "laravel/framework": "5.7.*", 12 | "laravel/tinker": "^1.0", 13 | "sevenshi/serverchan": "^1.0" 14 | }, 15 | "require-dev": { 16 | "beyondcode/laravel-dump-server": "^1.0", 17 | "filp/whoops": "^2.0", 18 | "fzaninotto/faker": "^1.4", 19 | "mockery/mockery": "^1.0", 20 | "nunomaduro/collision": "^2.0", 21 | "phpunit/phpunit": "^7.0" 22 | }, 23 | "autoload": { 24 | "classmap": [ 25 | "database/seeds", 26 | "database/factories" 27 | ], 28 | "psr-4": { 29 | "App\\": "app/" 30 | } 31 | }, 32 | "autoload-dev": { 33 | "psr-4": { 34 | "Tests\\": "tests/" 35 | } 36 | }, 37 | "extra": { 38 | "laravel": { 39 | "dont-discover": [ 40 | ] 41 | } 42 | }, 43 | "scripts": { 44 | "post-root-package-install": [ 45 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 46 | ], 47 | "post-create-project-cmd": [ 48 | "@php artisan key:generate --ansi" 49 | ], 50 | "post-autoload-dump": [ 51 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 52 | "@php artisan package:discover --ansi" 53 | ] 54 | }, 55 | "config": { 56 | "preferred-install": "dist", 57 | "sort-packages": true, 58 | "optimize-autoloader": true 59 | }, 60 | "minimum-stability": "dev", 61 | "prefer-stable": true 62 | } 63 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /app/ChatTask/ServerChanTask.php: -------------------------------------------------------------------------------- 1 | channel = [ 20 | 'a'=>config('serverchan.a'), //sw群组 21 | 'b'=>config('serverchan.b'), //php群组 22 | 'c'=>config('serverchan.c') //go群组 23 | ]; 24 | 25 | $this->data = $data; 26 | 27 | } 28 | 29 | public function handle() 30 | { 31 | $domain = env('APP_URL'); 32 | $message = $this->data['params']['name']."说了:\n".$this->data['message']."\n"; 33 | $message .= "来自于"."[sevenshi的webim](".$domain.")"."\n"; 34 | 35 | switch ($this->data['roomid']){ 36 | case 'a': 37 | try{ 38 | $response = Seven::setTitle('来自sw群组')->setMessage($message)->setChannel($this->channel['a'])->pushbear(); 39 | }catch (\Exception $e){ 40 | echo $e->getMessage(); 41 | } 42 | break; 43 | case 'b': 44 | try{ 45 | $response = Seven::setTitle('来自php群组')->setMessage($message)->setChannel($this->channel['b'])->pushbear(); 46 | }catch (\Exception $e){ 47 | echo $e->getMessage(); 48 | } 49 | break; 50 | case 'c': 51 | try{ 52 | $response = Seven::setTitle('来自go群组')->setMessage($message)->setChannel($this->channel['c'])->pushbear(); 53 | }catch (\Exception $e){ 54 | echo $e->getMessage(); 55 | } 56 | break; 57 | 58 | default: 59 | break; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | try { 11 | window.Popper = require('popper.js').default; 12 | window.$ = window.jQuery = require('jquery'); 13 | 14 | require('bootstrap'); 15 | } catch (e) {} 16 | 17 | /** 18 | * We'll load the axios HTTP library which allows us to easily issue requests 19 | * to our Laravel back-end. This library automatically handles sending the 20 | * CSRF token as a header based on the value of the "XSRF" token cookie. 21 | */ 22 | 23 | window.axios = require('axios'); 24 | 25 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 26 | 27 | /** 28 | * Next we will register the CSRF Token as a common header with Axios so that 29 | * all outgoing HTTP requests automatically have it attached. This is just 30 | * a simple convenience so we don't have to attach every token manually. 31 | */ 32 | 33 | let token = document.head.querySelector('meta[name="csrf-token"]'); 34 | 35 | if (token) { 36 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 37 | } else { 38 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 39 | } 40 | 41 | /** 42 | * Echo exposes an expressive API for subscribing to channels and listening 43 | * for events that are broadcast by Laravel. Echo and event broadcasting 44 | * allows your team to easily build robust real-time web applications. 45 | */ 46 | 47 | // import Echo from 'laravel-echo' 48 | 49 | // window.Pusher = require('pusher-js'); 50 | 51 | // window.Echo = new Echo({ 52 | // broadcaster: 'pusher', 53 | // key: process.env.MIX_PUSHER_APP_KEY, 54 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 55 | // encrypted: true 56 | // }); 57 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => ['required', 'string', 'max:255'], 53 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 54 | 'password' => ['required', 'string', 'min:6', 'confirmed'], 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return \App\User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => Hash::make($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => public_path('images/uploads'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM cmptech/auto_alpine_php7_runtime_with_swoole_latest 2 | 3 | # install basic lib for cmp 4 | RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/main" > /etc/apk/repositories \ 5 | && echo "http://nl.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories \ 6 | && echo "http://nl.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repositories \ 7 | && echo "nameserver 8.8.8.8" >> /etc/resolv.conf && apk update && apk upgrade \ 8 | && apk add \ 9 | php7-openssl \ 10 | php7-sqlite3 \ 11 | php7-pear \ 12 | php7-gmp \ 13 | php7-pdo_mysql \ 14 | php7-pcntl \ 15 | php7-common \ 16 | php7-xsl \ 17 | php7-fpm \ 18 | php7-mysqlnd \ 19 | php7-redis \ 20 | php7-snmp \ 21 | php7-mbstring \ 22 | php7-timezonedb \ 23 | php7-xmlreader \ 24 | php7-pdo_sqlite \ 25 | php7-exif \ 26 | php7-opcache \ 27 | php7-posix \ 28 | php7-session \ 29 | php7-gettext \ 30 | php7-json \ 31 | php7-xml \ 32 | php7-mongodb \ 33 | php7 \ 34 | php7-iconv \ 35 | php7-sysvshm \ 36 | php7-curl \ 37 | php7-shmop \ 38 | php7-odbc \ 39 | php7-phar \ 40 | php7-pdo_pgsql \ 41 | php7-imap \ 42 | php7-pdo_dblib \ 43 | php7-pgsql \ 44 | php7-pdo_odbc \ 45 | php7-zip \ 46 | php7-cgi \ 47 | php7-ctype \ 48 | php7-mcrypt \ 49 | php7-bcmath \ 50 | php7-calendar \ 51 | php7-tidy \ 52 | php7-dom \ 53 | php7-sockets \ 54 | php7-memcached \ 55 | php7-soap \ 56 | php7-sysvmsg \ 57 | php7-zlib \ 58 | php7-ssh2 \ 59 | php7-ftp \ 60 | php7-sysvsem \ 61 | php7-pdo \ 62 | php7-bz2 \ 63 | php7-mysqli \ 64 | vim wget curl bash openssl \ 65 | && rm -rf /var/cache/apk/* \ 66 | && rm -rf /tmp/* \ 67 | && ln -s /usr/sbin/php-fpm7 /usr/sbin/php-fpm 68 | 69 | COPY php.ini /etc/php7/ 70 | #COPY php.ini /etc/php7/conf.d/50-setting.ini 71 | #ADD default_entry.sh /root/ 72 | #COPY php-fpm.conf /etc/php7/php-fpm.conf 73 | 74 | #EXPOSE 9000 75 | #EXPOSE 9501 76 | RUN php -i 77 | #CMD ["/root/default_entry.sh"] 78 | #CMD ["php-fpm7", "-F"] 79 | 80 | # Register the COMPOSER_HOME environment variable 81 | ENV COMPOSER_HOME /composer 82 | 83 | # Add global binary directory to PATH and make sure to re-export it 84 | ENV PATH /composer/vendor/bin:$PATH 85 | 86 | # Allow Composer to be run as root 87 | ENV COMPOSER_ALLOW_SUPERUSER 1 88 | 89 | # Setup the Composer installer 90 | RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \ 91 | && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \ 92 | && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" 93 | 94 | RUN php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --snapshot && rm -rf /tmp/composer-setup.php 95 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Log Channels 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the log channels for your application. Out of 27 | | the box, Laravel uses the Monolog PHP logging library. This gives 28 | | you a variety of powerful log handlers / formatters to utilize. 29 | | 30 | | Available Drivers: "single", "daily", "slack", "syslog", 31 | | "errorlog", "monolog", 32 | | "custom", "stack" 33 | | 34 | */ 35 | 36 | 'channels' => [ 37 | 'stack' => [ 38 | 'driver' => 'stack', 39 | 'channels' => ['daily'], 40 | ], 41 | 42 | 'single' => [ 43 | 'driver' => 'single', 44 | 'path' => storage_path('logs/laravel.log'), 45 | 'level' => 'debug', 46 | ], 47 | 48 | 'daily' => [ 49 | 'driver' => 'daily', 50 | 'path' => storage_path('logs/laravel.log'), 51 | 'level' => 'debug', 52 | 'days' => 14, 53 | ], 54 | 55 | 'slack' => [ 56 | 'driver' => 'slack', 57 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 58 | 'username' => 'Laravel Log', 59 | 'emoji' => ':boom:', 60 | 'level' => 'critical', 61 | ], 62 | 63 | 'papertrail' => [ 64 | 'driver' => 'monolog', 65 | 'level' => 'debug', 66 | 'handler' => SyslogUdpHandler::class, 67 | 'handler_with' => [ 68 | 'host' => env('PAPERTRAIL_URL'), 69 | 'port' => env('PAPERTRAIL_PORT'), 70 | ], 71 | ], 72 | 73 | 'stderr' => [ 74 | 'driver' => 'monolog', 75 | 'handler' => StreamHandler::class, 76 | 'with' => [ 77 | 'stream' => 'php://stderr', 78 | ], 79 | ], 80 | 81 | 'syslog' => [ 82 | 'driver' => 'syslog', 83 | 'level' => 'debug', 84 | ], 85 | 86 | 'errorlog' => [ 87 | 'driver' => 'errorlog', 88 | 'level' => 'debug', 89 | ], 90 | ], 91 | 92 | ]; 93 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => env('SQS_KEY', 'your-public-key'), 54 | 'secret' => env('SQS_SECRET', 'your-secret-key'), 55 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 56 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 57 | 'region' => env('SQS_REGION', 'us-east-1'), 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => env('REDIS_QUEUE', 'default'), 64 | 'retry_after' => 90, 65 | 'block_for' => null, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Cache Stores 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Here you may define all of the cache "stores" for your application as 28 | | well as their drivers. You may even define multiple stores for the 29 | | same cache driver to group types of items stored in your caches. 30 | | 31 | */ 32 | 33 | 'stores' => [ 34 | 35 | 'apc' => [ 36 | 'driver' => 'apc', 37 | ], 38 | 39 | 'array' => [ 40 | 'driver' => 'array', 41 | ], 42 | 43 | 'database' => [ 44 | 'driver' => 'database', 45 | 'table' => 'cache', 46 | 'connection' => null, 47 | ], 48 | 49 | 'file' => [ 50 | 'driver' => 'file', 51 | 'path' => storage_path('framework/cache/data'), 52 | ], 53 | 54 | 'memcached' => [ 55 | 'driver' => 'memcached', 56 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 57 | 'sasl' => [ 58 | env('MEMCACHED_USERNAME'), 59 | env('MEMCACHED_PASSWORD'), 60 | ], 61 | 'options' => [ 62 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 63 | ], 64 | 'servers' => [ 65 | [ 66 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 67 | 'port' => env('MEMCACHED_PORT', 11211), 68 | 'weight' => 100, 69 | ], 70 | ], 71 | ], 72 | 73 | 'redis' => [ 74 | 'driver' => 'redis', 75 | 'connection' => 'cache', 76 | ], 77 | 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Cache Key Prefix 83 | |-------------------------------------------------------------------------- 84 | | 85 | | When utilizing a RAM based store such as APC or Memcached, there might 86 | | be other applications utilizing the same cache. So, we'll specify a 87 | | value to get prefixed to all our keys so we can avoid collisions. 88 | | 89 | */ 90 | 91 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | ], 39 | 40 | 'api' => [ 41 | 'throttle:60,1', 42 | 'bindings', 43 | ], 44 | ]; 45 | 46 | /** 47 | * The application's route middleware. 48 | * 49 | * These middleware may be assigned to groups or used individually. 50 | * 51 | * @var array 52 | */ 53 | protected $routeMiddleware = [ 54 | 'auth' => \App\Http\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 58 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 59 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 60 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 62 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 63 | ]; 64 | 65 | /** 66 | * The priority-sorted list of middleware. 67 | * 68 | * This forces the listed middleware to always be in the given order. 69 | * 70 | * @var array 71 | */ 72 | protected $middlewarePriority = [ 73 | \Illuminate\Session\Middleware\StartSession::class, 74 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 75 | \App\Http\Middleware\Authenticate::class, 76 | \Illuminate\Session\Middleware\AuthenticateSession::class, 77 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 78 | \Illuminate\Auth\Middleware\Authorize::class, 79 | ]; 80 | } 81 | -------------------------------------------------------------------------------- /public/js/xlyjs.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | $.extend({ app: { method: {}, module: {} } }); 3 | /* 消息提示 */ 4 | $.extend($.app.method, { tip: 5 | function (msg) { 6 | alert(msg); 7 | } 8 | }); 9 | /* 点击上传 */ 10 | $.extend($.app.method, {'uploadOption': {}}, { upload: 11 | function(action, callbackurl,callback, check){ 12 | var option = { 13 | action : action, 14 | id : 'app-upload-when-click-div-' + new Date().getTime(), 15 | onload : false, 16 | dialog : null, 17 | callback : callback, 18 | check : check, 19 | method : { 20 | callback: function(that){ 21 | if(!$.app.method.uploadOption.onload) return false; 22 | var text = that.contentWindow.document.body.innerHTML; 23 | $('#' + $.app.method.uploadOption.id).remove(); 24 | try{ 25 | var obj = $.parseJSON(text); 26 | }catch(e){} 27 | console.log(obj); 28 | if(!obj){ 29 | $.app.method.tip('数据返回格式有误'); 30 | return false; 31 | } 32 | //上次成功后执行回调函数 33 | if(typeof $.app.method.uploadOption.callback == 'function') return $.app.method.uploadOption.callback(obj); 34 | }, 35 | submit: function(that){ 36 | var check = true; 37 | //验证上传文件函数 38 | if(typeof $.app.method.uploadOption.check == 'function'){ 39 | if(!$.app.method.uploadOption.check($('#' + $.app.method.uploadOption.id).find('form input[type="file"]:first').val())){ 40 | check = false; 41 | } 42 | } 43 | //验证通过后直接上传 44 | if(check){ 45 | $.app.method.uploadOption.onload = true; 46 | try{ 47 | $(that).parent('form:first').trigger('submit'); 48 | }catch(e){ 49 | $('#' + $.app.method.uploadOption.id).remove(); 50 | $.app.method.tip(e.message); 51 | } 52 | } 53 | } 54 | } 55 | }; 56 | 57 | if(typeof option.action != 'string'){ 58 | $.app.method.tip('未设置上传地址!'); 59 | return false; 60 | } 61 | $.app.method.uploadOption = option; 62 | 63 | var html = []; 64 | html.push('
'); 65 | html.push(''); 66 | html.push('
'); 67 | html.push(''); 68 | html.push(''); 69 | html.push('
'); 70 | html.push('
'); 71 | $(html.join('')).appendTo('body'); 72 | //IE由于安全限制不允许直接用js选择文件并上传 73 | if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){ 74 | $.app.method.uploadOption.dialog = $('#' + $.app.method.uploadOption.id).dialog({title: '请选择文件',iconCls: 'icons-application-application_form_add',width: 280,modal: true}); 75 | }else{ 76 | $('#' + $.app.method.uploadOption.id).find('input[type="file"][name="upload"]:first').trigger('click'); 77 | } 78 | return false; 79 | } 80 | }); 81 | })(jQuery); -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /public/svg/404.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/ChatTask/ChatTask.php: -------------------------------------------------------------------------------- 1 | data = $data; 21 | } 22 | 23 | public function handle() 24 | { 25 | $swoole = app('swoole'); 26 | $pushMsg = array('code'=>0,'msg'=>'','data'=>array()); 27 | $data = json_decode($this->data,true); 28 | 29 | switch( $data['task'] ){ 30 | case 'open': 31 | $pushMsg = ChatService::open( $data ); 32 | if (is_array($pushMsg)){ 33 | var_dump($pushMsg); 34 | } 35 | $swoole->push( $data['fd'] , json_encode($pushMsg) ); 36 | return 'Finished'; 37 | case 'nologin': 38 | $pushMsg = ChatService::noLogin( $data ); 39 | $swoole->push( $data['fd'] ,json_encode($pushMsg)); 40 | return "Finished"; 41 | case 'login': 42 | $pushMsg = ChatService::doLogin( $data ); 43 | break; 44 | case 'logout': 45 | $pushMsg = ChatService::doLogout($data); 46 | break; 47 | case 'change': 48 | $pushMsg = ChatService::change( $data ); 49 | break; 50 | case 'new': 51 | $pushMsg = ChatService::sendNewMsg( $data ); 52 | break; 53 | case 'secretnew': 54 | $pushMsg = ChatService::sendSecretMsg( $data ); 55 | //对方在线才可以私聊信息 56 | if ($pushMsg){ 57 | $this->sendMsgBySecret($swoole,$pushMsg,$data['send_fd']); 58 | } 59 | return "Finished"; 60 | } 61 | if ($pushMsg){ 62 | $this->sendMsg($swoole,$pushMsg,$data['fd']); 63 | } 64 | return "Finished"; 65 | } 66 | 67 | // 可选的,完成事件,任务处理完后的逻辑,运行在Worker进程中,可以投递任务 68 | public function finish() 69 | { 70 | $data = json_decode($this->data,true); 71 | if ($data['task']=='new'){ 72 | Task::deliver(new ServerChanTask($data)); // 投递其他任务 73 | } 74 | } 75 | 76 | //群发,广播,给所有人 77 | private function sendMsg($swoole,$pushMsg,$myfd){ 78 | 79 | echo "当前服务器共有 ".count(app('swoole')->ws_usersTable). " 个连接\n"; 80 | foreach(app('swoole')->ws_usersTable as $key => $row) { 81 | if($row['fd'] === $myfd){ 82 | $pushMsg['data']['mine'] = 1; 83 | } else { 84 | $pushMsg['data']['mine'] = 0; 85 | } 86 | 87 | $swoole->push($row['fd'], json_encode($pushMsg)); 88 | } 89 | } 90 | 91 | //只广播给同个房间的人 92 | private function sendMsgOnlyRoom($swoole,$pushMsg,$myfd) 93 | { 94 | $userArr = app('swoole')->ws_roomsTable->get($pushMsg['data']['roomid']); 95 | if ($userArr) { 96 | $userArr = json_decode($userArr['users'], true); 97 | echo "当前房间共有 " . count($userArr) . " 个连接\n"; 98 | foreach ($userArr as $row){ 99 | if($row === $myfd){ 100 | $pushMsg['data']['mine'] = 1; 101 | } else { 102 | $pushMsg['data']['mine'] = 0; 103 | } 104 | $swoole->push($row, json_encode($pushMsg)); 105 | } 106 | } 107 | } 108 | 109 | //私聊发信息 110 | private function sendMsgBySecret($swoole,$pushMsg,$myfd) 111 | { 112 | //判断用户是否在线 113 | $user = app('swoole')->ws_usersTable->get('user'.$pushMsg['data']['receive_fd']); 114 | if ($user){ 115 | //发送给发送方 116 | if ($myfd == $pushMsg['data']['send_fd']){ 117 | $pushMsg['data']['mine'] = 1; 118 | $swoole->push($pushMsg['data']['send_fd'], json_encode($pushMsg)); 119 | } 120 | 121 | //发送给接受方 122 | $pushMsg['data']['mine'] = 0; 123 | $swoole->push($pushMsg['data']['receive_fd'], json_encode($pushMsg)); 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /public/js/face.js: -------------------------------------------------------------------------------- 1 | var face = { 2 | facePath:[ 3 | {faceName:"微笑",facePath:"0_1.gif"}, 4 | {faceName:"撇嘴",facePath:"1_2.gif"}, 5 | {faceName:"色",facePath:"2_3.gif"}, 6 | {faceName:"发呆",facePath:"3_4.gif"}, 7 | {faceName:"得意",facePath:"4_5.gif"}, 8 | {faceName:"流泪",facePath:"5_6.gif"}, 9 | {faceName:"害羞",facePath:"6_7.gif"}, 10 | {faceName:"闭嘴",facePath:"7_8.gif"}, 11 | {faceName:"大哭",facePath:"9_9.gif"}, 12 | {faceName:"尴尬",facePath:"10_10.gif"}, 13 | {faceName:"发怒",facePath:"11_11.gif"}, 14 | {faceName:"调皮",facePath:"12_12.gif"}, 15 | {faceName:"龇牙",facePath:"13_13.gif"}, 16 | {faceName:"惊讶",facePath:"14_14.gif"}, 17 | {faceName:"难过",facePath:"15_15.gif"}, 18 | {faceName:"酷",facePath:"16_16.gif"}, 19 | {faceName:"冷汗",facePath:"17_17.gif"}, 20 | {faceName:"抓狂",facePath:"18_18.gif"}, 21 | {faceName:"吐",facePath:"19_19.gif"}, 22 | {faceName:"偷笑",facePath:"20_20.gif"}, 23 | {faceName:"可爱",facePath:"21_21.gif"}, 24 | {faceName:"白眼",facePath:"22_22.gif"}, 25 | {faceName:"傲慢",facePath:"23_23.gif"}, 26 | {faceName:"饥饿",facePath:"24_24.gif"}, 27 | {faceName:"困",facePath:"25_25.gif"}, 28 | {faceName:"惊恐",facePath:"26_26.gif"}, 29 | {faceName:"流汗",facePath:"27_27.gif"}, 30 | {faceName:"憨笑",facePath:"28_28.gif"}, 31 | {faceName:"大兵",facePath:"29_29.gif"}, 32 | {faceName:"奋斗",facePath:"30_30.gif"}, 33 | {faceName:"咒骂",facePath:"31_31.gif"}, 34 | {faceName:"疑问",facePath:"32_32.gif"}, 35 | {faceName:"嘘",facePath:"33_33.gif"}, 36 | {faceName:"晕",facePath:"34_34.gif"}, 37 | {faceName:"折磨",facePath:"35_35.gif"}, 38 | {faceName:"衰",facePath:"36_36.gif"}, 39 | {faceName:"骷髅",facePath:"37_37.gif"}, 40 | {faceName:"敲打",facePath:"38_38.gif"}, 41 | {faceName:"再见",facePath:"39_39.gif"}, 42 | {faceName:"擦汗",facePath:"40_40.gif"}, 43 | 44 | {faceName:"抠鼻",facePath:"41_41.gif"}, 45 | {faceName:"鼓掌",facePath:"42_42.gif"}, 46 | {faceName:"糗大了",facePath:"43_43.gif"}, 47 | {faceName:"坏笑",facePath:"44_44.gif"}, 48 | {faceName:"左哼哼",facePath:"45_45.gif"}, 49 | {faceName:"右哼哼",facePath:"46_46.gif"}, 50 | {faceName:"哈欠",facePath:"47_47.gif"}, 51 | {faceName:"鄙视",facePath:"48_48.gif"}, 52 | {faceName:"委屈",facePath:"49_49.gif"}, 53 | {faceName:"快哭了",facePath:"50_50.gif"}, 54 | {faceName:"阴险",facePath:"51_51.gif"}, 55 | {faceName:"亲亲",facePath:"52_52.gif"}, 56 | {faceName:"吓",facePath:"53_53.gif"}, 57 | {faceName:"可怜",facePath:"54_54.gif"}, 58 | {faceName:"菜刀",facePath:"55_55.gif"}, 59 | {faceName:"西瓜",facePath:"56_56.gif"}, 60 | {faceName:"啤酒",facePath:"57_57.gif"}, 61 | {faceName:"篮球",facePath:"58_58.gif"}, 62 | {faceName:"乒乓",facePath:"59_59.gif"}, 63 | {faceName:"拥抱",facePath:"78_78.gif"}, 64 | {faceName:"握手",facePath:"81_81.gif"} 65 | ], 66 | init : function (){ 67 | var isShowImg=false; 68 | $(".emotion_btn").click(function(){ 69 | if(isShowImg==false){ 70 | isShowImg=true; 71 | if($(".faceDiv").children().length==0){ 72 | for(var i=0;i"); 74 | } 75 | $(".faceDiv>img").click(function(){ 76 | isShowImg=false; 77 | face.insertAtCursor($("#chattext")[0],"["+$(this).attr("title")+"]"); 78 | }); 79 | } 80 | $(".faceDiv").css("display","block"); 81 | }else{ 82 | isShowImg=false; 83 | $(".faceDiv").css("display","none"); 84 | } 85 | }); 86 | }, 87 | insertAtCursor:function(myField, myValue) { 88 | if (document.selection) { 89 | myField.focus(); 90 | sel = document.selection.createRange(); 91 | sel.text = myValue; 92 | sel.select(); 93 | } else if (myField.selectionStart || myField.selectionStart == "0") { 94 | var startPos = myField.selectionStart; 95 | var endPos = myField.selectionEnd; 96 | var restoreTop = myField.scrollTop; 97 | myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); 98 | if (restoreTop > 0) { 99 | myField.scrollTop = restoreTop; 100 | } 101 | myField.focus(); 102 | myField.selectionStart = startPos + myValue.length; 103 | myField.selectionEnd = startPos + myValue.length; 104 | } else { 105 | myField.value += myValue; 106 | myField.focus(); 107 | } 108 | $(".faceDiv").css("display","none"); 109 | } 110 | } -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /app/Services/WebSocketService.php: -------------------------------------------------------------------------------- 1 | 'open', 29 | 'fd' => $request->fd 30 | ); 31 | 32 | $task = new ChatTask(json_encode($data)); 33 | $ret = Task::deliver($task); 34 | echo $request->fd."open\n"; 35 | } 36 | 37 | public function onMessage(\swoole_websocket_server $server, \swoole_websocket_frame $frame) 38 | { 39 | $data = json_decode( $frame->data , true ); 40 | switch($data['type']){ 41 | case 1://登录 42 | $data = array( 43 | 'task' => 'login', 44 | 'params' => array( 45 | 'name' => $data['name'], 46 | 'email' => $data['email'] 47 | ), 48 | 'fd' => $frame->fd, 49 | 'roomid' =>$data['roomid'] 50 | ); 51 | if(!$data['params']['name'] || !$data['params']['email'] ){ 52 | $data['task'] = "nologin"; 53 | } 54 | $task = new ChatTask(json_encode($data)); 55 | $ret = Task::deliver($task); 56 | echo $frame->fd."登陆\n"; 57 | break; 58 | case 2: //新消息 59 | $data = array( 60 | 'task' => 'new', 61 | 'params' => array( 62 | 'name' => $data['name'], 63 | 'avatar' => $data['avatar'] 64 | ), 65 | 'c' => $data['c'], 66 | 'message' => $data['message'], 67 | 'fd' => $frame->fd, 68 | 'roomid' => $data['roomid'] 69 | ); 70 | $task = new ChatTask(json_encode($data)); 71 | $ret = Task::deliver($task); 72 | echo $frame->fd."发了消息\n"; 73 | break; 74 | 75 | case 3: // 改变房间 76 | $data = array( 77 | 'task' => 'change', 78 | 'params' => array( 79 | 'name' => $data['name'], 80 | 'avatar' => $data['avatar'], 81 | 'email'=>$data['email'], 82 | ), 83 | 'fd' => $frame->fd, 84 | 'oldroomid' => $data['oldroomid'], 85 | 'roomid' => $data['roomid'] 86 | ); 87 | $task = new ChatTask(json_encode($data)); 88 | $ret = Task::deliver($task); 89 | echo $frame->fd."改变房间\n"; 90 | break; 91 | case 4: //私聊信息消息 92 | $data = array( 93 | 'task' => 'secretnew', 94 | 'params' => array( 95 | 'name' => $data['send_name'], 96 | 'avatar' => $data['send_avatar'] 97 | ), 98 | 'c' => $data['c'], 99 | 'message' => $data['message'], 100 | 'send_fd' => $frame->fd, 101 | 'receive_fd' => $data['receive_fd'] 102 | ); 103 | $task = new ChatTask(json_encode($data)); 104 | $ret = Task::deliver($task); 105 | echo $frame->fd."向".$data['receive_fd']."发起了私聊\n"; 106 | break; 107 | default : 108 | $server->push($frame->fd, json_encode(array('code'=>0,'msg'=>'type error'))); 109 | } 110 | } 111 | //登出,记得laravels.php中的dispatch_mode要设置为2 112 | public function onClose(\swoole_websocket_server $server, $fd, $reactorId) 113 | { 114 | //获取登出的用户 115 | $user = app('swoole')->ws_usersTable->get('user'.$fd); 116 | if ($user){ 117 | $data = array( 118 | 'task' => 'logout', 119 | 'params' => array( 120 | 'name' => $user['name'], 121 | 'roomid'=>$user['roomid'] 122 | ), 123 | 'fd' => $fd 124 | ); 125 | $task = new ChatTask(json_encode($data)); 126 | $ret = Task::deliver($task); 127 | } 128 | 129 | echo "client {$fd} closed\n"; 130 | 131 | } 132 | 133 | } -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 41 | ], 42 | 43 | 'mysql' => [ 44 | 'driver' => 'mysql', 45 | 'host' => env('DB_HOST', '127.0.0.1'), 46 | 'port' => env('DB_PORT', '3306'), 47 | 'database' => env('DB_DATABASE', 'forge'), 48 | 'username' => env('DB_USERNAME', 'forge'), 49 | 'password' => env('DB_PASSWORD', ''), 50 | 'unix_socket' => env('DB_SOCKET', ''), 51 | 'charset' => 'utf8mb4', 52 | 'collation' => 'utf8mb4_unicode_ci', 53 | 'prefix' => '', 54 | 'prefix_indexes' => true, 55 | 'strict' => true, 56 | 'engine' => null, 57 | ], 58 | 59 | 'pgsql' => [ 60 | 'driver' => 'pgsql', 61 | 'host' => env('DB_HOST', '127.0.0.1'), 62 | 'port' => env('DB_PORT', '5432'), 63 | 'database' => env('DB_DATABASE', 'forge'), 64 | 'username' => env('DB_USERNAME', 'forge'), 65 | 'password' => env('DB_PASSWORD', ''), 66 | 'charset' => 'utf8', 67 | 'prefix' => '', 68 | 'prefix_indexes' => true, 69 | 'schema' => 'public', 70 | 'sslmode' => 'prefer', 71 | ], 72 | 73 | 'sqlsrv' => [ 74 | 'driver' => 'sqlsrv', 75 | 'host' => env('DB_HOST', 'localhost'), 76 | 'port' => env('DB_PORT', '1433'), 77 | 'database' => env('DB_DATABASE', 'forge'), 78 | 'username' => env('DB_USERNAME', 'forge'), 79 | 'password' => env('DB_PASSWORD', ''), 80 | 'charset' => 'utf8', 81 | 'prefix' => '', 82 | 'prefix_indexes' => true, 83 | ], 84 | 85 | ], 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Migration Repository Table 90 | |-------------------------------------------------------------------------- 91 | | 92 | | This table keeps track of all the migrations that have already run for 93 | | your application. Using this information, we can determine which of 94 | | the migrations on disk haven't actually been run in the database. 95 | | 96 | */ 97 | 98 | 'migrations' => 'migrations', 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Redis Databases 103 | |-------------------------------------------------------------------------- 104 | | 105 | | Redis is an open source, fast, and advanced key-value store that also 106 | | provides a richer body of commands than a typical key-value system 107 | | such as APC or Memcached. Laravel makes it easy to dig right in. 108 | | 109 | */ 110 | 111 | 'redis' => [ 112 | 113 | 'client' => 'predis', 114 | 115 | 'default' => [ 116 | 'host' => env('REDIS_HOST', '127.0.0.1'), 117 | 'password' => env('REDIS_PASSWORD', null), 118 | 'port' => env('REDIS_PORT', 6379), 119 | 'database' => env('REDIS_DB', 0), 120 | ], 121 | 122 | 'cache' => [ 123 | 'host' => env('REDIS_HOST', '127.0.0.1'), 124 | 'password' => env('REDIS_PASSWORD', null), 125 | 'port' => env('REDIS_PORT', 6379), 126 | 'database' => env('REDIS_CACHE_DB', 1), 127 | ], 128 | 129 | ], 130 | 131 | ]; 132 | -------------------------------------------------------------------------------- /config/laravels.php: -------------------------------------------------------------------------------- 1 | env('LARAVELS_LISTEN_IP', '0.0.0.0'), 8 | 'listen_port' => env('LARAVELS_LISTEN_PORT', 9090), 9 | 'socket_type' => env('LARAVELS_SOCKET_TYPE', defined('SWOOLE_SOCK_TCP') ? \SWOOLE_SOCK_TCP : 1), 10 | 'enable_gzip' => env('LARAVELS_ENABLE_GZIP', false), 11 | 'enable_coroutine_runtime' => false, 12 | 'server' => env('LARAVELS_SERVER', 'LaravelS'), 13 | 'handle_static' => env('LARAVELS_HANDLE_STATIC', true), 14 | 'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()), 15 | 'inotify_reload' => [ 16 | 'enable' => env('LARAVELS_INOTIFY_RELOAD', false), 17 | 'watch_path' => base_path(), 18 | 'file_types' => ['.php'], 19 | 'excluded_dirs' => [], 20 | 'log' => true, 21 | ], 22 | 'websocket' => [ 23 | 'enable' => true, 24 | 'handler' => \App\Services\WebSocketService::class, 25 | ], 26 | 'sockets' => [ 27 | ], 28 | 'processes' => [ 29 | ], 30 | 'timer' => [ 31 | 'enable' => false, 32 | 'jobs' => [ 33 | // Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab 34 | //\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class, 35 | // Two ways to configure parameters: 36 | // [\App\Jobs\XxxCronJob::class, [1000, true]], // Pass in parameters when registering 37 | // \App\Jobs\XxxCronJob::class, // Override the corresponding method to return the configuration 38 | ], 39 | ], 40 | 'events' => [ 41 | ], 42 | 'swoole_tables' => [ 43 | //定义登陆用户的信息 44 | 'ws_users' =>[ 45 | 'size' => 102400,//Table的最大行数 46 | 'column' => [// Table的列定义$roomid,$fd,$name,$email,$avatar 47 | ['name' => 'roomid', 'type' => \swoole_table::TYPE_STRING, 'size' => 8], 48 | ['name' => 'fd', 'type' => \swoole_table::TYPE_INT, 'size' => 8], 49 | ['name' => 'name', 'type' => \swoole_table::TYPE_STRING, 'size' => 100], 50 | ['name' => 'email', 'type' => \swoole_table::TYPE_STRING, 'size' => 100], 51 | ['name' => 'avatar', 'type' => \swoole_table::TYPE_STRING, 'size' => 100], 52 | ['name' => 'time', 'type' => \swoole_table::TYPE_STRING, 'size' => 50], 53 | ] 54 | ], 55 | 'ws_rooms'=>[ 56 | 'size' => 102400,//Table的最大行数 57 | 'column' => [// Table的列定义$roomid,$fd,$name,$email,$avatar 58 | ['name' => 'users', 'type' => \swoole_table::TYPE_STRING, 'size' => 1024], 59 | ] 60 | ], 61 | 'ws_roomUsers'=>[ 62 | 'size' => 102400,//Table的最大行数 63 | 'column' => [// Table的列定义$roomid,$fd,$name,$email,$avatar 64 | ['name' => 'infos', 'type' => \swoole_table::TYPE_STRING, 'size' => 1024], 65 | ] 66 | ], 67 | ], 68 | 'register_providers' => [ 69 | ], 70 | 'swoole' => [ 71 | 'daemonize' => env('LARAVELS_DAEMONIZE', false), 72 | 'dispatch_mode' => 2, 73 | 'reactor_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 4, 74 | 'worker_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 8, 75 | 'task_worker_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 8, 76 | 'task_ipc_mode' => 1, 77 | 'task_max_request' => 5000, 78 | 'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp', 79 | 'message_queue_key' => ftok(base_path('public/index.php'), 1), 80 | 'max_request' => 3000, 81 | 'open_tcp_nodelay' => true, 82 | 'pid_file' => storage_path('laravels.pid'), 83 | 'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))), 84 | 'log_level' => 4, 85 | 'document_root' => base_path('public'), 86 | 'buffer_output_size' => 16 * 1024 * 1024, 87 | 'socket_buffer_size' => 128 * 1024 * 1024, 88 | 'package_max_length' => 4 * 1024 * 1024, 89 | 'reload_async' => true, 90 | 'max_wait_time' => 60, 91 | 'enable_reuse_port' => true, 92 | 'enable_coroutine' => false, 93 | 94 | /** 95 | * More settings of Swoole 96 | * @see https://wiki.swoole.com/wiki/page/274.html Chinese 97 | * @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration English 98 | */ 99 | ], 100 | ]; 101 | -------------------------------------------------------------------------------- /config/chat.php: -------------------------------------------------------------------------------- 1 | [ 14 | 'a' => 'sw交流组', 15 | 'b' => 'php交流组', 16 | 'c' => 'go交流组', 17 | 18 | ], 19 | 'domain'=>DOMAIN, 20 | 21 | 'emotion'=>array( 22 | "[微笑]" => '', 23 | "[尴尬]" => '', 24 | "[发怒]" => '', 25 | "[调皮]" => '', 26 | "[龇牙]" => '', 27 | "[惊讶]" => '', 28 | "[难过]" => '', 29 | "[酷]" => '', 30 | "[冷汗]" => '', 31 | "[抓狂]" => '', 32 | "[吐]" => '', 33 | "[撇嘴]" => '', 34 | "[偷笑]" => '', 35 | "[可爱]" => '', 36 | "[白眼]" => '', 37 | "[傲慢]" => '', 38 | "[饥饿]" => '', 39 | "[困]" => '', 40 | "[惊恐]" => '', 41 | "[流汗]" => '', 42 | "[憨笑]" => '', 43 | "[大兵]" => '', 44 | "[色]" => '', 45 | "[奋斗]" => '', 46 | "[咒骂]" => '', 47 | "[疑问]" => '', 48 | "[嘘]" => '', 49 | "[晕]" => '', 50 | "[折磨]" => '', 51 | "[衰]" => '', 52 | "[骷髅]" => '', 53 | "[敲打]" => '', 54 | "[再见]" => '', 55 | "[发呆]" => '', 56 | "[擦汗]" => '', 57 | "[抠鼻]" => '', 58 | "[鼓掌]" => '', 59 | "[糗大了]" => '', 60 | "[坏笑]" => '', 61 | "[左哼哼]" => '', 62 | "[右哼哼]" => '', 63 | "[哈欠]" => '', 64 | "[鄙视]" => '', 65 | "[委屈]" => '', 66 | "[得意]" => '', 67 | "[快哭了]" => '', 68 | "[阴险]" => '', 69 | "[亲亲]" => '', 70 | "[吓]" => '', 71 | "[可怜]" => '', 72 | "[菜刀]" => '', 73 | "[西瓜]" => '', 74 | "[啤酒]" => '', 75 | "[篮球]" => '', 76 | "[乒乓]" => '', 77 | "[流泪]" => '', 78 | "[害羞]" => '', 79 | "[拥抱]" => '', 80 | "[闭嘴]" => '', 81 | "[握手]" => '', 82 | "[大哭]" => '', 83 | ) 84 | ]; 85 | -------------------------------------------------------------------------------- /public/svg/503.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/js/create.div.js: -------------------------------------------------------------------------------- 1 | /*创建div dom*/ 2 | var cdiv = { 3 | userlists : function(roomid,is_none){ 4 | var arr = []; 5 | arr = [ '
']; 6 | return arr.join(''); 7 | }, 8 | chatlists : function(roomid,is_none){ 9 | var arr = []; 10 | arr = [ '
']; 11 | return arr.join(''); 12 | }, 13 | render : function(template,params){ 14 | var arr = []; 15 | switch(template){ 16 | case 'mymessage': 17 | arr = [ 18 | '
', params.newmessage,'
' 19 | ]; 20 | break; 21 | case 'mySecretMessage': 22 | arr = [ 23 | '
', params.newmessage,'
' 24 | ]; 25 | break; 26 | case 'chatLine': 27 | arr = [ 28 | '
',params.name,'',params.time,'
',params.newmessage,'
' 29 | ]; 30 | break; 31 | 32 | case 'secretChatLine': 33 | arr = [ 34 | '
',params.send_name,'',params.time,'
',params.newmessage,'
' 35 | ]; 36 | break; 37 | 38 | case 'user': 39 | arr = [ 40 | '

',params.name,'

',params.time,'
' 41 | ]; 42 | break; 43 | case 'newlogin': 44 | arr = [ 45 | '
系统消息:欢迎 ',params.name,' 加入群聊
' 46 | ]; 47 | break; 48 | case 'logout': 49 | arr = [ 50 | '
系统消息: ',params.name,' 退出了群聊
' 51 | ]; 52 | break; 53 | case 'my': 54 | arr = [ 55 | '

',params.name,'

' 56 | ]; 57 | break; 58 | case 'secretChat': 59 | arr = [ 60 | '

',params.name,'

' 61 | ]; 62 | break; 63 | case 'secretChatSend': 64 | arr = [ 65 | '

',params.send_name,'

' 66 | ]; 67 | break; 68 | case 'rooms': 69 | arr = [ 70 | '' 71 | ]; 72 | break; 73 | } 74 | return arr.join(''); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/Services/ChatUsersService.php: -------------------------------------------------------------------------------- 1 | $v){ 18 | if(isset($this->$k)){ 19 | $this->$k = $v; 20 | } 21 | } 22 | } 23 | } 24 | 25 | /** 26 | * @return array|mixed 27 | * swoole_table版本 28 | */ 29 | public function getOnlineUsers(){ 30 | $rooms = config('chat.rooms'); 31 | $online_users = array(); 32 | foreach($rooms as $_k => $_v){ 33 | $infos = app('swoole')->ws_roomUsersTable->get('roomUsersInfo'.$_k); 34 | if ($infos){ 35 | $online_users[$_k] =json_decode($infos['infos'],true); 36 | }else{ 37 | $online_users[$_k] =[]; 38 | } 39 | } 40 | return $online_users; 41 | } 42 | 43 | 44 | /** 45 | * @return bool|int 46 | * swoole_table版本 47 | */ 48 | public function save(){ 49 | 50 | $userInfo = ['roomid'=>$this->roomid,'fd'=>$this->fd,'name'=>$this->name,'avatar'=>$this->avatar,'email'=>$this->email,'time'=>date("H:i",time())]; 51 | //插入到room表,给房间增加一个用户 52 | $userArr = app('swoole')->ws_roomsTable->get($this->roomid); 53 | if ($userArr){ 54 | $userArr = json_decode($userArr['users'],true); 55 | array_push($userArr,$this->fd); 56 | }else{ 57 | $userArr = [$this->fd]; 58 | } 59 | app('swoole')->ws_roomsTable->set($this->roomid, ['users' => json_encode($userArr)]); 60 | 61 | //插入到用户信息表 62 | app('swoole')->ws_usersTable->set('user'.$this->fd,$userInfo); 63 | 64 | //插入到房间用户信息表 65 | $roomUsersArr = app('swoole')->ws_roomUsersTable->get('roomUsersInfo'.$this->roomid); 66 | if ($roomUsersArr){ 67 | $roomUsersArr = json_decode($roomUsersArr['infos'],true); 68 | array_push($roomUsersArr,$userInfo); 69 | }else{ 70 | $roomUsersArr = [$userInfo]; 71 | } 72 | app('swoole')->ws_roomUsersTable->set('roomUsersInfo'.$this->roomid,['infos'=>json_encode($roomUsersArr)]); 73 | 74 | return true; 75 | } 76 | 77 | /** 78 | * @param $oldroomid 79 | * @param $fd 80 | * @param $newroomid 81 | * @return bool 82 | * swoole_table版本 83 | */ 84 | public function changeUser($oldroomid,$fd,$newroomid){ 85 | 86 | //更改用户的roomid 87 | $user = app('swoole')->ws_usersTable->get('user'.$fd); 88 | if ($user){ 89 | $userInfo = [ 90 | 'roomid'=>$newroomid, 91 | 'fd'=>$user['fd'], 92 | 'name'=>$user['name'], 93 | 'avatar'=>$user['avatar'], 94 | 'email'=>$user['email'], 95 | 'time'=>date("H:i",time()) 96 | ]; 97 | 98 | app('swoole')->ws_usersTable->set('user'.$fd,$userInfo); 99 | } 100 | 101 | //新房间里新增用户 102 | $userArrnew = app('swoole')->ws_roomsTable->get($newroomid); 103 | if ($userArrnew){ 104 | $userArrnew = json_decode($userArrnew['users'],true); 105 | array_push($userArrnew,$fd); 106 | }else{ 107 | $userArrnew = [$fd]; 108 | } 109 | app('swoole')->ws_roomsTable->set($newroomid, ['users' => json_encode($userArrnew)]); 110 | 111 | 112 | //从老房间里删除用户 113 | $userArr = app('swoole')->ws_roomsTable->get($oldroomid); 114 | if ($userArr){ 115 | $userArr = json_decode($userArr['users'],true); 116 | $key=array_search($fd,$userArr); 117 | array_splice($userArr,$key,1); 118 | app('swoole')->ws_roomsTable->set($oldroomid, ['users' => json_encode($userArr)]); 119 | } 120 | 121 | 122 | //插入到房间用户信息表 123 | $userInfo = ['roomid'=>$newroomid,'fd'=>$fd,'name'=>$this->name,'avatar'=>$this->avatar,'email'=>$this->email,'time'=>date("H:i",time())]; 124 | 125 | $roomUsersArr = app('swoole')->ws_roomUsersTable->get('roomUsersInfo'.$newroomid); 126 | if ($roomUsersArr){ 127 | $roomUsersArr = json_decode($roomUsersArr['infos'],true); 128 | array_push($roomUsersArr,$userInfo); 129 | }else{ 130 | $roomUsersArr = [$userInfo]; 131 | } 132 | app('swoole')->ws_roomUsersTable->set('roomUsersInfo'.$newroomid,['infos'=>json_encode($roomUsersArr)]); 133 | 134 | 135 | //从房间用户信息删除 136 | $infos = app('swoole')->ws_roomUsersTable->get('roomUsersInfo'.$oldroomid); 137 | if ($infos){ 138 | $infos = json_decode($infos['infos'],true); 139 | if (!empty($infos)){ 140 | foreach ($infos as $info_key => $row){ 141 | if ($row['fd']==$fd){ 142 | array_splice($infos,$info_key,1); 143 | break; 144 | } 145 | } 146 | app('swoole')->ws_roomUsersTable->set('roomUsersInfo'.$oldroomid,['infos'=>json_encode($infos)]); 147 | } 148 | } 149 | 150 | 151 | 152 | return true; 153 | } 154 | 155 | public function getUsersByRoom($roomid) 156 | { 157 | $infos = app('swoole')->ws_roomUsersTable->get('roomUsersInfo'.$roomid); 158 | if ($infos){ 159 | $users =json_decode($infos['infos'],true); 160 | }else{ 161 | $users =[]; 162 | } 163 | return $users; 164 | } 165 | } -------------------------------------------------------------------------------- /resources/views/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 公共聊天室-基于swoole扩展php开发 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
    17 |
  • swoole群组

    sw群组

  • 18 |
  • php群组

    php群组

  • 19 |
  • go群组

    go群组

  • 20 |
21 |
22 |
23 | 29 |
30 | 34 | 84 |
85 |
86 |
87 |
88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | Fork me on GitHub 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /public/svg/403.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION', null), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | When using the "apc" or "memcached" session drivers, you may specify a 96 | | cache store that should be used for these sessions. This value must 97 | | correspond with one of the application's configured cache stores. 98 | | 99 | */ 100 | 101 | 'store' => env('SESSION_STORE', null), 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Session Sweeping Lottery 106 | |-------------------------------------------------------------------------- 107 | | 108 | | Some session drivers must manually sweep their storage location to get 109 | | rid of old sessions from storage. Here are the chances that it will 110 | | happen on a given request. By default, the odds are 2 out of 100. 111 | | 112 | */ 113 | 114 | 'lottery' => [2, 100], 115 | 116 | /* 117 | |-------------------------------------------------------------------------- 118 | | Session Cookie Name 119 | |-------------------------------------------------------------------------- 120 | | 121 | | Here you may change the name of the cookie used to identify a session 122 | | instance by ID. The name specified here will get used every time a 123 | | new session cookie is created by the framework for every driver. 124 | | 125 | */ 126 | 127 | 'cookie' => env( 128 | 'SESSION_COOKIE', 129 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 130 | ), 131 | 132 | /* 133 | |-------------------------------------------------------------------------- 134 | | Session Cookie Path 135 | |-------------------------------------------------------------------------- 136 | | 137 | | The session cookie path determines the path for which the cookie will 138 | | be regarded as available. Typically, this will be the root path of 139 | | your application but you are free to change this when necessary. 140 | | 141 | */ 142 | 143 | 'path' => '/', 144 | 145 | /* 146 | |-------------------------------------------------------------------------- 147 | | Session Cookie Domain 148 | |-------------------------------------------------------------------------- 149 | | 150 | | Here you may change the domain of the cookie used to identify a session 151 | | in your application. This will determine which domains the cookie is 152 | | available to in your application. A sensible default has been set. 153 | | 154 | */ 155 | 156 | 'domain' => env('SESSION_DOMAIN', null), 157 | 158 | /* 159 | |-------------------------------------------------------------------------- 160 | | HTTPS Only Cookies 161 | |-------------------------------------------------------------------------- 162 | | 163 | | By setting this option to true, session cookies will only be sent back 164 | | to the server if the browser has a HTTPS connection. This will keep 165 | | the cookie from being sent to you if it can not be done securely. 166 | | 167 | */ 168 | 169 | 'secure' => env('SESSION_SECURE_COOKIE', false), 170 | 171 | /* 172 | |-------------------------------------------------------------------------- 173 | | HTTP Access Only 174 | |-------------------------------------------------------------------------- 175 | | 176 | | Setting this value to true will prevent JavaScript from accessing the 177 | | value of the cookie and the cookie will only be accessible through 178 | | the HTTP protocol. You are free to modify this option if needed. 179 | | 180 | */ 181 | 182 | 'http_only' => true, 183 | 184 | /* 185 | |-------------------------------------------------------------------------- 186 | | Same-Site Cookies 187 | |-------------------------------------------------------------------------- 188 | | 189 | | This option determines how your cookies behave when cross-site requests 190 | | take place, and can be used to mitigate CSRF attacks. By default, we 191 | | do not enable this as other CSRF protection services are in place. 192 | | 193 | | Supported: "lax", "strict" 194 | | 195 | */ 196 | 197 | 'same_site' => null, 198 | 199 | ]; 200 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_format' => 'The :attribute does not match the format :format.', 36 | 'different' => 'The :attribute and :other must be different.', 37 | 'digits' => 'The :attribute must be :digits digits.', 38 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 39 | 'dimensions' => 'The :attribute has invalid image dimensions.', 40 | 'distinct' => 'The :attribute field has a duplicate value.', 41 | 'email' => 'The :attribute must be a valid email address.', 42 | 'exists' => 'The selected :attribute is invalid.', 43 | 'file' => 'The :attribute must be a file.', 44 | 'filled' => 'The :attribute field must have a value.', 45 | 'gt' => [ 46 | 'numeric' => 'The :attribute must be greater than :value.', 47 | 'file' => 'The :attribute must be greater than :value kilobytes.', 48 | 'string' => 'The :attribute must be greater than :value characters.', 49 | 'array' => 'The :attribute must have more than :value items.', 50 | ], 51 | 'gte' => [ 52 | 'numeric' => 'The :attribute must be greater than or equal :value.', 53 | 'file' => 'The :attribute must be greater than or equal :value kilobytes.', 54 | 'string' => 'The :attribute must be greater than or equal :value characters.', 55 | 'array' => 'The :attribute must have :value items or more.', 56 | ], 57 | 'image' => 'The :attribute must be an image.', 58 | 'in' => 'The selected :attribute is invalid.', 59 | 'in_array' => 'The :attribute field does not exist in :other.', 60 | 'integer' => 'The :attribute must be an integer.', 61 | 'ip' => 'The :attribute must be a valid IP address.', 62 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 63 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 64 | 'json' => 'The :attribute must be a valid JSON string.', 65 | 'lt' => [ 66 | 'numeric' => 'The :attribute must be less than :value.', 67 | 'file' => 'The :attribute must be less than :value kilobytes.', 68 | 'string' => 'The :attribute must be less than :value characters.', 69 | 'array' => 'The :attribute must have less than :value items.', 70 | ], 71 | 'lte' => [ 72 | 'numeric' => 'The :attribute must be less than or equal :value.', 73 | 'file' => 'The :attribute must be less than or equal :value kilobytes.', 74 | 'string' => 'The :attribute must be less than or equal :value characters.', 75 | 'array' => 'The :attribute must not have more than :value items.', 76 | ], 77 | 'max' => [ 78 | 'numeric' => 'The :attribute may not be greater than :max.', 79 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 80 | 'string' => 'The :attribute may not be greater than :max characters.', 81 | 'array' => 'The :attribute may not have more than :max items.', 82 | ], 83 | 'mimes' => 'The :attribute must be a file of type: :values.', 84 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 85 | 'min' => [ 86 | 'numeric' => 'The :attribute must be at least :min.', 87 | 'file' => 'The :attribute must be at least :min kilobytes.', 88 | 'string' => 'The :attribute must be at least :min characters.', 89 | 'array' => 'The :attribute must have at least :min items.', 90 | ], 91 | 'not_in' => 'The selected :attribute is invalid.', 92 | 'not_regex' => 'The :attribute format is invalid.', 93 | 'numeric' => 'The :attribute must be a number.', 94 | 'present' => 'The :attribute field must be present.', 95 | 'regex' => 'The :attribute format is invalid.', 96 | 'required' => 'The :attribute field is required.', 97 | 'required_if' => 'The :attribute field is required when :other is :value.', 98 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 99 | 'required_with' => 'The :attribute field is required when :values is present.', 100 | 'required_with_all' => 'The :attribute field is required when :values are present.', 101 | 'required_without' => 'The :attribute field is required when :values is not present.', 102 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 103 | 'same' => 'The :attribute and :other must match.', 104 | 'size' => [ 105 | 'numeric' => 'The :attribute must be :size.', 106 | 'file' => 'The :attribute must be :size kilobytes.', 107 | 'string' => 'The :attribute must be :size characters.', 108 | 'array' => 'The :attribute must contain :size items.', 109 | ], 110 | 'string' => 'The :attribute must be a string.', 111 | 'timezone' => 'The :attribute must be a valid zone.', 112 | 'unique' => 'The :attribute has already been taken.', 113 | 'uploaded' => 'The :attribute failed to upload.', 114 | 'url' => 'The :attribute format is invalid.', 115 | 'uuid' => 'The :attribute must be a valid UUID.', 116 | 117 | /* 118 | |-------------------------------------------------------------------------- 119 | | Custom Validation Language Lines 120 | |-------------------------------------------------------------------------- 121 | | 122 | | Here you may specify custom validation messages for attributes using the 123 | | convention "attribute.rule" to name the lines. This makes it quick to 124 | | specify a specific custom language line for a given attribute rule. 125 | | 126 | */ 127 | 128 | 'custom' => [ 129 | 'attribute-name' => [ 130 | 'rule-name' => 'custom-message', 131 | ], 132 | ], 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Custom Validation Attributes 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The following language lines are used to swap our attribute placeholder 140 | | with something more reader friendly such as "E-Mail Address" instead 141 | | of "email". This simply helps us make our message more expressive. 142 | | 143 | */ 144 | 145 | 'attributes' => [], 146 | 147 | ]; 148 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | your application so that it is used when running Artisan tasks. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. We have gone 64 | | ahead and set this to a sensible default for you out of the box. 65 | | 66 | */ 67 | 68 | 'timezone' => 'UTC', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by the translation service provider. You are free to set this value 77 | | to any of the locales which will be supported by the application. 78 | | 79 | */ 80 | 81 | 'locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Application Fallback Locale 86 | |-------------------------------------------------------------------------- 87 | | 88 | | The fallback locale determines the locale to use when the current one 89 | | is not available. You may change the value to correspond to any of 90 | | the language folders that are provided through your application. 91 | | 92 | */ 93 | 94 | 'fallback_locale' => 'en', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Faker Locale 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This locale will be used by the Faker PHP library when generating fake 102 | | data for your database seeds. For example, this will be used to get 103 | | localized telephone numbers, street address information and more. 104 | | 105 | */ 106 | 107 | 'faker_locale' => 'en_US', 108 | 109 | /* 110 | |-------------------------------------------------------------------------- 111 | | Encryption Key 112 | |-------------------------------------------------------------------------- 113 | | 114 | | This key is used by the Illuminate encrypter service and should be set 115 | | to a random, 32 character string, otherwise these encrypted strings 116 | | will not be safe. Please do this before deploying an application! 117 | | 118 | */ 119 | 120 | 'key' => env('APP_KEY'), 121 | 122 | 'cipher' => 'AES-256-CBC', 123 | 124 | /* 125 | |-------------------------------------------------------------------------- 126 | | Autoloaded Service Providers 127 | |-------------------------------------------------------------------------- 128 | | 129 | | The service providers listed here will be automatically loaded on the 130 | | request to your application. Feel free to add your own services to 131 | | this array to grant expanded functionality to your applications. 132 | | 133 | */ 134 | 135 | 'providers' => [ 136 | 137 | /* 138 | * Laravel Framework Service Providers... 139 | */ 140 | Illuminate\Auth\AuthServiceProvider::class, 141 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 142 | Illuminate\Bus\BusServiceProvider::class, 143 | Illuminate\Cache\CacheServiceProvider::class, 144 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 145 | Illuminate\Cookie\CookieServiceProvider::class, 146 | Illuminate\Database\DatabaseServiceProvider::class, 147 | Illuminate\Encryption\EncryptionServiceProvider::class, 148 | Illuminate\Filesystem\FilesystemServiceProvider::class, 149 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 150 | Illuminate\Hashing\HashServiceProvider::class, 151 | Illuminate\Mail\MailServiceProvider::class, 152 | Illuminate\Notifications\NotificationServiceProvider::class, 153 | Illuminate\Pagination\PaginationServiceProvider::class, 154 | Illuminate\Pipeline\PipelineServiceProvider::class, 155 | Illuminate\Queue\QueueServiceProvider::class, 156 | Illuminate\Redis\RedisServiceProvider::class, 157 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 158 | Illuminate\Session\SessionServiceProvider::class, 159 | Illuminate\Translation\TranslationServiceProvider::class, 160 | Illuminate\Validation\ValidationServiceProvider::class, 161 | Illuminate\View\ViewServiceProvider::class, 162 | 163 | /* 164 | * Package Service Providers... 165 | */ 166 | 167 | /* 168 | * Application Service Providers... 169 | */ 170 | App\Providers\AppServiceProvider::class, 171 | App\Providers\AuthServiceProvider::class, 172 | // App\Providers\BroadcastServiceProvider::class, 173 | App\Providers\EventServiceProvider::class, 174 | App\Providers\RouteServiceProvider::class, 175 | 176 | SwooleTW\Http\LaravelServiceProvider::class, 177 | 178 | 179 | ], 180 | 181 | /* 182 | |-------------------------------------------------------------------------- 183 | | Class Aliases 184 | |-------------------------------------------------------------------------- 185 | | 186 | | This array of class aliases will be registered when this application 187 | | is started. However, feel free to register as many as you wish as 188 | | the aliases are "lazy" loaded so they don't hinder performance. 189 | | 190 | */ 191 | 192 | 'aliases' => [ 193 | 194 | 'App' => Illuminate\Support\Facades\App::class, 195 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 196 | 'Auth' => Illuminate\Support\Facades\Auth::class, 197 | 'Blade' => Illuminate\Support\Facades\Blade::class, 198 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 199 | 'Bus' => Illuminate\Support\Facades\Bus::class, 200 | 'Cache' => Illuminate\Support\Facades\Cache::class, 201 | 'Config' => Illuminate\Support\Facades\Config::class, 202 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 203 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 204 | 'DB' => Illuminate\Support\Facades\DB::class, 205 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 206 | 'Event' => Illuminate\Support\Facades\Event::class, 207 | 'File' => Illuminate\Support\Facades\File::class, 208 | 'Gate' => Illuminate\Support\Facades\Gate::class, 209 | 'Hash' => Illuminate\Support\Facades\Hash::class, 210 | 'Lang' => Illuminate\Support\Facades\Lang::class, 211 | 'Log' => Illuminate\Support\Facades\Log::class, 212 | 'Mail' => Illuminate\Support\Facades\Mail::class, 213 | 'Notification' => Illuminate\Support\Facades\Notification::class, 214 | 'Password' => Illuminate\Support\Facades\Password::class, 215 | 'Queue' => Illuminate\Support\Facades\Queue::class, 216 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 217 | 'Redis' => Illuminate\Support\Facades\Redis::class, 218 | 'Request' => Illuminate\Support\Facades\Request::class, 219 | 'Response' => Illuminate\Support\Facades\Response::class, 220 | 'Route' => Illuminate\Support\Facades\Route::class, 221 | 'Schema' => Illuminate\Support\Facades\Schema::class, 222 | 'Session' => Illuminate\Support\Facades\Session::class, 223 | 'Storage' => Illuminate\Support\Facades\Storage::class, 224 | 'URL' => Illuminate\Support\Facades\URL::class, 225 | 'Validator' => Illuminate\Support\Facades\Validator::class, 226 | 'View' => Illuminate\Support\Facades\View::class, 227 | 228 | ], 229 | 230 | ]; 231 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 基于laravel+swoole的在线聊天室 2 | 3 | 4 | ## 目录 5 | 6 | - [介绍](#introduction) 7 | - [技术栈](#versions) 8 | - [安装](#installation) 9 | - [配置](#configuration) 10 | - [启动](#run) 11 | 12 | ## Introduction 13 | 14 | 想法参考了这个[项目](https://github.com/hellosee/swoole-webim-demo)这个项目没有任何框架直接使用扩展来开发,并且以文本形式存储用户数据, 15 | 本项目参考了其前端页面样式以及部分逻辑使用laravel以及使用laravel-swoole的package [laravel-x](https://github.com/hhxsv5/laravel-s) 16 | 重构了整个项目,其中使用了swoole的http_server,swoole_websocket_server,异步任务,和swoole_table。 17 | 18 | - 用户数据使用了swoole_table进行存储,一旦重启所有数据都消失了 19 | - 所有ws请求都是用异步任务进行处理 20 | - 使用http_server代替nginx 21 | - 使用swoole_websocket_server搭建ws服务 22 | 23 | 主要代码在以下几个目录 24 | 25 | - app/ChatTask 异步任务 26 | - app/Services wbsocket服务处理 27 | - public 静态资源目录 28 | 29 | 30 | 以上知识点均可在[swoole](https://www.swoole.com/)官网进行查看 31 | 32 | **目前实现的功能有** : 33 | 34 | > * 支持群聊 35 | > * 支持发送文字 36 | > * 支持登出 37 | > * 支持切换房间聊天功能 38 | > * 支持私聊,可以点点私聊 39 | > * 显示未读消息数 40 | > * 接入server酱,使用的是我开发的[sevenshi-serverchan](https://github.com/shisiying/sevenshi-serverchan),订阅过后可以收到群聊的推送 41 | 42 | 你可以直接看一下最终的效果,请查看 [http://webim.xhzyxed.cn/](http://webim.xhzyxed.cn/) 。 43 | 44 | 如果想看看代码原理,请请查看三篇文章: 45 | 46 | # Versions 47 | > Laravel 5.5 48 | > swoole 49 | 50 | 因为使用 `swoole`扩展 所以需要一些基本的安装需求: 51 | 52 | * [swoole扩展的安装](https://www.swoole.com/) 53 | 54 | ## installation 55 | 56 | ```bash 57 | git clone https://github.com/shisiying/webim 58 | composer install 59 | php artisan laravels publish 60 | 选择laravel-s和sevenshi-serverchan进行发布 61 | 62 | ``` 63 | 64 | ## configuration 65 | 66 | 在config路径下 67 | 68 | 69 | - laravels.php 70 | ```bash 71 | env('LARAVELS_LISTEN_IP', '0.0.0.0'), 78 | 'listen_port' => env('LARAVELS_LISTEN_PORT', 你的端口), 79 | 'socket_type' => env('LARAVELS_SOCKET_TYPE', defined('SWOOLE_SOCK_TCP') ? \SWOOLE_SOCK_TCP : 1), 80 | 'enable_gzip' => env('LARAVELS_ENABLE_GZIP', false), 81 | 'enable_coroutine_runtime' => false, 82 | 'server' => env('LARAVELS_SERVER', 'LaravelS'), 83 | 'handle_static' => env('LARAVELS_HANDLE_STATIC', true), 84 | 'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()), 85 | 'inotify_reload' => [ 86 | 'enable' => env('LARAVELS_INOTIFY_RELOAD', false), 87 | 'watch_path' => base_path(), 88 | 'file_types' => ['.php'], 89 | 'excluded_dirs' => [], 90 | 'log' => true, 91 | ], 92 | 'websocket' => [ 93 | 'enable' => true, 94 | 'handler' => \App\Services\WebSocketService::class, 95 | ], 96 | 'sockets' => [ 97 | ], 98 | 'processes' => [ 99 | ], 100 | 'timer' => [ 101 | 'enable' => false, 102 | 'jobs' => [ 103 | // Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab 104 | //\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class, 105 | // Two ways to configure parameters: 106 | // [\App\Jobs\XxxCronJob::class, [1000, true]], // Pass in parameters when registering 107 | // \App\Jobs\XxxCronJob::class, // Override the corresponding method to return the configuration 108 | ], 109 | ], 110 | 'events' => [ 111 | ], 112 | 'swoole_tables' => [ 113 | //定义登陆用户的信息 114 | 'ws_users' =>[ 115 | 'size' => 102400,//Table的最大行数 116 | 'column' => [// Table的列定义$roomid,$fd,$name,$email,$avatar 117 | ['name' => 'roomid', 'type' => \swoole_table::TYPE_STRING, 'size' => 8], 118 | ['name' => 'fd', 'type' => \swoole_table::TYPE_INT, 'size' => 8], 119 | ['name' => 'name', 'type' => \swoole_table::TYPE_STRING, 'size' => 100], 120 | ['name' => 'email', 'type' => \swoole_table::TYPE_STRING, 'size' => 100], 121 | ['name' => 'avatar', 'type' => \swoole_table::TYPE_STRING, 'size' => 100], 122 | ['name' => 'time', 'type' => \swoole_table::TYPE_STRING, 'size' => 50], 123 | ] 124 | ], 125 | 'ws_rooms'=>[ 126 | 'size' => 102400,//Table的最大行数 127 | 'column' => [// Table的列定义$roomid,$fd,$name,$email,$avatar 128 | ['name' => 'users', 'type' => \swoole_table::TYPE_STRING, 'size' => 1024], 129 | ] 130 | ], 131 | 'ws_roomUsers'=>[ 132 | 'size' => 102400,//Table的最大行数 133 | 'column' => [// Table的列定义$roomid,$fd,$name,$email,$avatar 134 | ['name' => 'infos', 'type' => \swoole_table::TYPE_STRING, 'size' => 1024], 135 | ] 136 | ], 137 | ], 138 | 'register_providers' => [ 139 | ], 140 | 'swoole' => [ 141 | 'daemonize' => env('LARAVELS_DAEMONIZE', false), 142 | 'dispatch_mode' => 2, 143 | 'reactor_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 4, 144 | 'worker_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 8, 145 | 'task_worker_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 8, 146 | 'task_ipc_mode' => 1, 147 | 'task_max_request' => 5000, 148 | 'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp', 149 | 'message_queue_key' => ftok(base_path('public/index.php'), 1), 150 | 'max_request' => 3000, 151 | 'open_tcp_nodelay' => true, 152 | 'pid_file' => storage_path('laravels.pid'), 153 | 'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))), 154 | 'log_level' => 4, 155 | 'document_root' => base_path('public'), 156 | 'buffer_output_size' => 16 * 1024 * 1024, 157 | 'socket_buffer_size' => 128 * 1024 * 1024, 158 | 'package_max_length' => 4 * 1024 * 1024, 159 | 'reload_async' => true, 160 | 'max_wait_time' => 60, 161 | 'enable_reuse_port' => true, 162 | 'enable_coroutine' => false, 163 | 164 | /** 165 | * More settings of Swoole 166 | * @see https://wiki.swoole.com/wiki/page/274.html Chinese 167 | * @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration English 168 | */ 169 | ], 170 | ]; 171 | 172 | 173 | ``` 174 | 175 | 记住,websocket_server跟http_server监听同个端口,只不过协议不同而已 176 | 177 | - chat.php 178 | ```bash 179 | define("DOMAIN","域名或者刚才设置的ip和端口"); 180 | ``` 181 | 182 | - serverchan.php 183 | 184 | ```bash 185 | 186 | 设置推送给群组的server配置 187 | return [ 188 | 'a'=>'6739-83848e2xxxxdfd5a74b30aca15d71ec5e961', //sw群组 189 | 'b'=>'6741-7c0b0355xxx85e7e2e86cc6edcdbc7bd',//php群组 190 | 'c'=>'6740-023ed322xxxxfds9c6e3d0e4b268a762622a'//go群组 191 | ]; 192 | ``` 193 | 194 | 195 | - init.js 196 | 197 | 配置public目录下的init.js 198 | ```bash 199 | var config = { 200 | 'domain' : "http://192.168.10.10:9090",//你的ip和端口,也就是laravel-s上设置的 201 | 'wsserver' : "ws://192.168.10.10:9090",//除了协议不同,其他ip跟端口是一致的 202 | } 203 | ``` 204 | 205 | - nginx配置 206 | 207 | 可参考以下配置 208 | ```bash 209 | map $http_upgrade $connection_upgrade { 210 | default upgrade; 211 | '' close; 212 | } 213 | upstream laravels { 214 | # 通过 IP:Port 连接 215 | server 127.0.0.1:5200 weight=5 max_fails=3 fail_timeout=30s; 216 | # 通过 UnixSocket Stream 连接,小诀窍:将socket文件放在/dev/shm目录下,可获得更好的性能 217 | #server unix:/xxxpath/laravel-s-test/storage/laravels.sock weight=5 max_fails=3 fail_timeout=30s; 218 | #server 192.168.1.1:5200 weight=3 max_fails=3 fail_timeout=30s; 219 | #server 192.168.1.2:5200 backup; 220 | keepalive 16; 221 | } 222 | server { 223 | listen 80; 224 | # 别忘了绑Host哟 225 | server_name laravels.com; 226 | root /xxxpath/laravel-s-test/public; 227 | access_log /yyypath/log/nginx/$server_name.access.log main; 228 | autoindex off; 229 | index index.html index.htm; 230 | # Nginx处理静态资源(建议开启gzip),LaravelS处理动态资源。 231 | location / { 232 | try_files $uri @laravels; 233 | } 234 | # 当请求PHP文件时直接响应404,防止暴露public/*.php 235 | #location ~* \.php$ { 236 | # return 404; 237 | #} 238 | # Http和WebSocket共存,Nginx通过location区分 239 | # !!! WebSocket连接时路径为/ws 240 | # Javascript: var ws = new WebSocket("ws://laravels.com/ws"); 241 | location =/ws { 242 | proxy_http_version 1.1; 243 | # proxy_connect_timeout 60s; 244 | # proxy_send_timeout 60s; 245 | # proxy_read_timeout:如果60秒内被代理的服务器没有响应数据给Nginx,那么Nginx会关闭当前连接;同时,Swoole的心跳设置也会影响连接的关闭 246 | # proxy_read_timeout 60s; 247 | proxy_set_header X-Real-IP $remote_addr; 248 | proxy_set_header X-Real-PORT $remote_port; 249 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 250 | proxy_set_header Host $http_host; 251 | proxy_set_header Scheme $scheme; 252 | proxy_set_header Server-Protocol $server_protocol; 253 | proxy_set_header Server-Name $server_name; 254 | proxy_set_header Server-Addr $server_addr; 255 | proxy_set_header Server-Port $server_port; 256 | proxy_set_header Upgrade $http_upgrade; 257 | proxy_set_header Connection $connection_upgrade; 258 | proxy_pass http://laravels; 259 | } 260 | location @laravels { 261 | proxy_http_version 1.1; 262 | # proxy_connect_timeout 60s; 263 | # proxy_send_timeout 60s; 264 | # proxy_read_timeout 60s; 265 | proxy_set_header X-Real-IP $remote_addr; 266 | proxy_set_header X-Real-PORT $remote_port; 267 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 268 | proxy_set_header Host $http_host; 269 | proxy_set_header Scheme $scheme; 270 | proxy_set_header Server-Protocol $server_protocol; 271 | proxy_set_header Server-Name $server_name; 272 | proxy_set_header Server-Addr $server_addr; 273 | proxy_set_header Server-Port $server_port; 274 | proxy_set_header Connection ""; 275 | proxy_pass http://laravels; 276 | } 277 | } 278 | ``` 279 | ## run 280 | ```bash 281 | 282 | 直接项目根目录下执行,加d可以守护态运行 283 | 284 | php artisan laravels start -d 285 | 286 | 287 | ``` 288 | 289 | 290 | ## License 291 | 292 | The MIT License (MIT). 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | -------------------------------------------------------------------------------- /app/Services/ChatService.php: -------------------------------------------------------------------------------- 1 | $_v){ 41 | $roomss[] = array( 42 | 'roomid' => $_k, 43 | 'roomname' => $_v 44 | ); 45 | } 46 | return $roomss; 47 | } 48 | 49 | /** 50 | * @return array|mixed 51 | * swoole_table版本 52 | */ 53 | public static function getOnlineUsers(){ 54 | $user = new ChatUsersService(); 55 | $lists = $user->getOnlineUsers(); 56 | return $lists; 57 | } 58 | 59 | //登陆 60 | public static function doLogin($data) 61 | { 62 | $domain = config('chat.domain'); 63 | $pushMsg['code'] = 1; 64 | $pushMsg['msg'] = $data['params']['name']."加入了群聊"; 65 | 66 | $pushMsg['data']['roomid'] = $data['roomid']; 67 | $pushMsg['data']['fd'] = $data['fd']; 68 | $pushMsg['data']['name'] = $data['params']['name']; 69 | $pushMsg['data']['avatar'] = $domain.'images/avatar/f1/f_'.rand(1,12).'.jpg'; 70 | $pushMsg['data']['time'] = date("H:i",time()); 71 | //增加房间的名字 72 | $pushMsg['data']['roomname'] = config('chat.rooms')[$data['roomid']]; 73 | 74 | self::login($data['roomid'],$data['fd'],$data['params']['name'],$data['params']['email'],$pushMsg['data']['avatar']); 75 | unset( $data ); 76 | return $pushMsg; 77 | } 78 | 79 | //登陆写入swoole_table中 80 | public static function login($roomid,$fd,$name,$email,$avatar){ 81 | if($name == ""){ 82 | $name = '游客'.time(); 83 | } 84 | if($email == ""){ 85 | $email = 'xxx@qq.com'; 86 | } 87 | if(!$name || !$email){ 88 | 89 | throw new Exception('Fill in all the required fields.'); 90 | } 91 | $user = new ChatUsersService(array( 92 | 'roomid' => $roomid, 93 | 'fd' => $fd, 94 | 'name' => htmlspecialchars($name), 95 | 'email' => $email, 96 | 'avatar' => $avatar 97 | )); 98 | if(!$user->save()){ 99 | throw new Exception('This nick is in use.'); 100 | } 101 | } 102 | 103 | //登出 104 | public static function doLogout($data) 105 | { 106 | echo "退出################"; 107 | var_dump($data); 108 | $roomid = $data['params']['roomid']; 109 | 110 | //从房间里删除用户 111 | $userArr = app('swoole')->ws_roomsTable->get($roomid); 112 | if ($userArr){ 113 | $userArr = json_decode($userArr['users'],true); 114 | $key=array_search($data['fd'],$userArr); 115 | array_splice($userArr,$key,1); 116 | app('swoole')->ws_roomsTable->set($roomid, ['users' => json_encode($userArr)]); 117 | } 118 | 119 | 120 | //从房间用户信息删除 121 | $infos = app('swoole')->ws_roomUsersTable->get('roomUsersInfo'.$roomid); 122 | var_dump($infos); 123 | if ($infos){ 124 | $infos = json_decode($infos['infos'],true); 125 | if (!empty($infos)){ 126 | foreach ($infos as $info_key => $row){ 127 | if ($row['fd']==$data['fd']){ 128 | array_splice($infos,$info_key,1); 129 | break; 130 | } 131 | } 132 | var_dump($infos); 133 | app('swoole')->ws_roomUsersTable->set('roomUsersInfo'.$roomid,['infos'=>json_encode($infos)]); 134 | } 135 | } 136 | echo "退出结束################"; 137 | 138 | 139 | //删除用户 140 | app('swoole')->ws_usersTable->del('user'.$data['fd']); 141 | 142 | $pushMsg['code'] = 3; 143 | $pushMsg['msg'] = $data['params']['name']."退出了群聊"; 144 | $pushMsg['data']['fd'] = $data['fd']; 145 | $pushMsg['data']['name'] = $data['params']['name']; 146 | $pushMsg['data']['roomid'] = $roomid; 147 | unset( $data ); 148 | return $pushMsg; 149 | } 150 | 151 | //改变房间 152 | public static function change( $data ){ 153 | $pushMsg['code'] = 6; 154 | $pushMsg['msg'] = '换房成功'; 155 | $user = new ChatUsersService(array( 156 | 'roomid' => $data['roomid'],//新的房间号 157 | 'fd' => $data['fd'], 158 | 'name' => htmlspecialchars($data['params']['name']), 159 | 'email' => $data['params']['email'], 160 | 'avatar' => $data['params']['avatar'] 161 | )); 162 | 163 | $is_copyed = $user->changeUser($data['oldroomid'],$data['fd'],$data['roomid']); 164 | 165 | if($is_copyed){ 166 | $pushMsg['data']['oldroomid'] = $data['oldroomid']; 167 | $pushMsg['data']['roomid'] = $data['roomid']; 168 | $pushMsg['data']['mine'] = 0; 169 | $pushMsg['data']['fd'] = $data['fd']; 170 | $pushMsg['data']['name'] = $data['params']['name']; 171 | $pushMsg['data']['avatar'] = $data['params']['avatar']; 172 | $pushMsg['data']['time'] = date("H:i",time()); 173 | unset( $data ); 174 | return $pushMsg; 175 | } 176 | 177 | return false; 178 | 179 | } 180 | 181 | //发送消息 182 | public static function sendNewMsg( $data ){ 183 | $pushMsg['code'] = 2; 184 | $pushMsg['msg'] = ""; 185 | $pushMsg['data']['roomid'] = $data['roomid']; 186 | $pushMsg['data']['fd'] = $data['fd']; 187 | $pushMsg['data']['name'] = $data['params']['name']; 188 | $pushMsg['data']['avatar'] = $data['params']['avatar']; 189 | $pushMsg['data']['newmessage'] = self::escape(htmlspecialchars($data['message'])); 190 | $pushMsg['data']['remains'] = array(); 191 | if($data['c'] == 'img'){ 192 | $pushMsg['data']['newmessage'] = ''; 193 | } else { 194 | $emotion = config('chat.emotion'); 195 | foreach($emotion as $_k => $_v){ 196 | $pushMsg['data']['newmessage'] = str_replace($_k,$_v,$pushMsg['data']['newmessage']); 197 | } 198 | $tmp = self::remind($data['roomid'],$pushMsg['data']['newmessage']); 199 | if($tmp['flag']){ 200 | $pushMsg['data']['newmessage'] = $tmp['msg']; 201 | $pushMsg['data']['remains'] = $tmp['remains']; 202 | } 203 | unset( $tmp ); 204 | } 205 | $pushMsg['data']['time'] = date("H:i",time()); 206 | unset( $data ); 207 | return $pushMsg; 208 | } 209 | 210 | //私聊发信息 211 | public static function sendSecretMsg($data) 212 | { 213 | //获取接受人信息 214 | if ( $receiver = app('swoole')->ws_usersTable->get('user'.$data['receive_fd'])){ 215 | $pushMsg['code'] = 7; 216 | $pushMsg['msg'] = ""; 217 | 218 | //发送人信息 219 | $pushMsg['data']['send_fd'] = $data['send_fd']; 220 | $pushMsg['data']['send_name'] = $data['params']['name']; 221 | $pushMsg['data']['send_avatar'] = $data['params']['avatar']; 222 | $pushMsg['data']['newmessage'] = self::escape(htmlspecialchars($data['message'])); 223 | $pushMsg['data']['remains'] = array(); 224 | 225 | //接受人信息 226 | $pushMsg['data']['receive_fd'] = $data['receive_fd']; 227 | $pushMsg['data']['receive_name'] = $receiver['name']; 228 | $pushMsg['data']['receive_avatar'] = $receiver['avatar']; 229 | 230 | 231 | if($data['c'] == 'img'){ 232 | $pushMsg['data']['newmessage'] = ''; 233 | } else { 234 | $emotion = config('chat.emotion'); 235 | foreach($emotion as $_k => $_v){ 236 | $pushMsg['data']['newmessage'] = str_replace($_k,$_v,$pushMsg['data']['newmessage']); 237 | } 238 | } 239 | $pushMsg['data']['time'] = date("H:i",time()); 240 | unset( $data ); 241 | return $pushMsg; 242 | } 243 | 244 | return false; 245 | 246 | 247 | } 248 | //匹配文本 249 | public static function remind($roomid,$msg){ 250 | $data = array(); 251 | if( $msg != ""){ 252 | $data['msg'] = $msg; 253 | //正则匹配出所有@的人来 254 | $s = preg_match_all( '~@(.+?) ~' , $msg, $matches ) ; 255 | $data['flag'] = false; 256 | if($s){ 257 | $data['flag'] = true; 258 | $m1 = array_unique( $matches[0] ); 259 | $m2 = array_unique( $matches[1] ); 260 | $user = new ChatUsersService(); 261 | $users = $user->getUsersByRoom($roomid); 262 | $m3 = array(); 263 | foreach($users as $_k => $_v){ 264 | $m3[$_v['name']] = $_v['fd']; 265 | } 266 | $i = 0; 267 | foreach($m2 as $_k => $_v){ 268 | if(array_key_exists($_v,$m3)){ 269 | $data['msg'] = str_replace($m1[$_k],''.trim($m1[$_k]).'',$data['msg']); 270 | $data['remains'][$i]['fd'] = $m3[$_v]; 271 | $data['remains'][$i]['name'] = $_v; 272 | $i++; 273 | } 274 | } 275 | unset($users); 276 | unset($m1,$m2,$m3); 277 | } 278 | } 279 | return $data; 280 | } 281 | 282 | //过滤文本 283 | public static function escape($input, $urldecode = 0) { 284 | if(is_array($input)){ 285 | foreach($input as $k=>$v){ 286 | $input[$k]=escape($v,$urldecode); 287 | } 288 | }else{ 289 | $input=trim($input); 290 | if ($urldecode == 1) { 291 | $input=str_replace(array('+'),array('{addplus}'),$input); 292 | $input = urldecode($input); 293 | $input=str_replace(array('{addplus}'),array('+'),$input); 294 | } 295 | // PHP版本大于5.4.0,直接转义字符 296 | if (strnatcasecmp(PHP_VERSION, '5.4.0') >= 0) { 297 | $input = addslashes($input); 298 | } else { 299 | // 魔法转义没开启,自动加反斜杠 300 | if (!get_magic_quotes_gpc()) { 301 | $input = addslashes($input); 302 | } 303 | } 304 | } 305 | //防止最后一个反斜杠引起SQL错误如 'abc\' 306 | if(substr($input,-1,1)=='\\') $input=$input."'";//$input=substr($input,0,strlen($input)-1); 307 | return $input; 308 | } 309 | } --------------------------------------------------------------------------------