Merge remote-tracking branch 'origin/sockets'

# Conflicts:
#	composer.lock
#	public/mix-manifest.json
This commit is contained in:
Čarodej
2022-03-10 07:14:08 +01:00
15 changed files with 1896 additions and 315 deletions

View File

@@ -11,6 +11,7 @@
"php": "^8.0.2",
"ext-json": "*",
"ext-pdo": "*",
"beyondcode/laravel-websockets": "^1.13",
"brianium/paratest": "^6.4.1",
"cocur/slugify": "^4.1",
"doctrine/dbal": "^2.13.7",
@@ -29,6 +30,7 @@
"league/flysystem-aws-s3-v3": "^3.0.9",
"makingcg/laravel-scout-tntsearch-driver": "dev-master",
"makingcg/subscription": "dev-main",
"pusher/pusher-php-server": "^7.0",
"spatie/data-transfer-object": "^3.7.3",
"spatie/laravel-backup": "^8.0.8",
"spatie/laravel-query-builder": "^5.0.0",

1891
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -174,7 +174,7 @@ return [
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
],

View File

@@ -35,7 +35,10 @@ return [
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
'encrypted' => true,
'host' => '192.168.1.112',
'port' => 6001,
'scheme' => 'http'
],
],

141
config/websockets.php Normal file
View File

@@ -0,0 +1,141 @@
<?php
use BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize;
return [
/*
* Set a custom dashboard configuration
*/
'dashboard' => [
'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
],
/*
* This package comes with multi tenancy out of the box. Here you can
* configure the different apps that can use the webSockets server.
*
* Optionally you specify capacity so you can limit the maximum
* concurrent connections for a specific app.
*
* Optionally you can disable client events so clients cannot send
* messages to each other via the webSockets.
*/
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
],
/*
* This class is responsible for finding the apps. The default provider
* will use the apps defined in this config file.
*
* You can create a custom provider by implementing the
* `AppProvider` interface.
*/
'app_provider' => BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider::class,
/*
* This array contains the hosts of which you want to allow incoming requests.
* Leave this empty if you want to accept requests from all hosts.
*/
'allowed_origins' => [
//
],
/*
* The maximum request size in kilobytes that is allowed for an incoming WebSocket request.
*/
'max_request_size_in_kb' => 250,
/*
* This path will be used to register the necessary routes for the package.
*/
'path' => 'laravel-websockets',
/*
* Dashboard Routes Middleware
*
* These middleware will be assigned to every dashboard route, giving you
* the chance to add your own middleware to this list or change any of
* the existing middleware. Or, you can simply stick with this list.
*/
'middleware' => [
'web',
Authorize::class,
],
'statistics' => [
/*
* This model will be used to store the statistics of the WebSocketsServer.
* The only requirement is that the model should extend
* `WebSocketsStatisticsEntry` provided by this package.
*/
'model' => \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry::class,
/**
* The Statistics Logger will, by default, handle the incoming statistics, store them
* and then release them into the database on each interval defined below.
*/
'logger' => BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class,
/*
* Here you can specify the interval in seconds at which statistics should be logged.
*/
'interval_in_seconds' => 60,
/*
* When the clean-command is executed, all recorded statistics older than
* the number of days specified here will be deleted.
*/
'delete_statistics_older_than_days' => 60,
/*
* Use an DNS resolver to make the requests to the statistics logger
* default is to resolve everything to 127.0.0.1.
*/
'perform_dns_lookup' => false,
],
/*
* Define the optional SSL context for your WebSocket connections.
* You can see all available options at: http://php.net/manual/en/context.ssl.php
*/
'ssl' => [
/*
* Path to local certificate file on filesystem. It must be a PEM encoded file which
* contains your certificate and private key. It can optionally contain the
* certificate chain of issuers. The private key also may be contained
* in a separate file specified by local_pk.
*/
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
/*
* Passphrase for your local_cert file.
*/
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
],
/*
* Channel Manager
* This class handles how channel persistence is handled.
* By default, persistence is stored in an array by the running webserver.
* The only requirement is that the class should implement
* `ChannelManager` interface provided by this package.
*/
'channel_manager' => \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager::class,
];

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWebSocketsStatisticsEntriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('websockets_statistics_entries', function (Blueprint $table) {
$table->increments('id');
$table->string('app_id');
$table->integer('peak_connection_count');
$table->integer('websocket_message_count');
$table->integer('api_message_count');
$table->nullableTimestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('websockets_statistics_entries');
}
}

23
package-lock.json generated
View File

@@ -5251,6 +5251,12 @@
"integrity": "sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ==",
"dev": true
},
"laravel-echo": {
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/laravel-echo/-/laravel-echo-1.11.3.tgz",
"integrity": "sha512-VNTnnoF8gK29ovxslnrFDt3xgrKiKKW1kTnKKO1A4kYVj4UCKmNO4x2ehRlfg2UTrG/oggwk95p+S9ftQYjXdw==",
"dev": true
},
"laravel-mix": {
"version": "6.0.43",
"resolved": "https://registry.npmjs.org/laravel-mix/-/laravel-mix-6.0.43.tgz",
@@ -7123,6 +7129,23 @@
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
},
"pusher-js": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/pusher-js/-/pusher-js-7.0.6.tgz",
"integrity": "sha512-I44FTlF2OfGNg/4xcxmFq/JqFzJswoQWtWCPq+DkCh31MFg3Qkm3bNFvTXU+c5KR19TyBZ9SYlYq2rrpJZzbIA==",
"dev": true,
"requires": {
"tweetnacl": "^1.0.3"
},
"dependencies": {
"tweetnacl": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",
"integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",
"dev": true
}
}
},
"qs": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz",

View File

@@ -13,11 +13,13 @@
"autoprefixer": "^10.4.2",
"axios": "^0.21.4",
"cross-env": "^5.1",
"laravel-echo": "^1.11.3",
"laravel-mix": "^6.0.43",
"postcss": "^8.4.7",
"prettier": "^2.5.1",
"prettier-plugin-import-sort": "0.0.7",
"prettier-plugin-tailwindcss": "^0.1.8",
"pusher-js": "^7.0.6",
"resolve-url-loader": "^2.3.1",
"sass": "^1.49.9",
"sass-loader": "^8.0.2",

View File

@@ -1,7 +1,7 @@
{
"/js/main.js": "/js/main.js",
"/chunks/request.js": "/chunks/request.js?id=001f737452e0d25a",
"/chunks/request-upload.js": "/chunks/request-upload.js?id=f50a50d2aa741c81",
"/chunks/request.js": "/chunks/request.js?id=3c8d8ec8f0f51d19",
"/chunks/request-upload.js": "/chunks/request-upload.js?id=12dcae76203db76f",
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=19a0784e59d768ec",
"/chunks/status-check.js": "/chunks/status-check.js?id=6bae83a7e38d3b1c",
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=0d001d4505d2f5e9",
@@ -9,13 +9,13 @@
"/chunks/environment-setup.js": "/chunks/environment-setup.js?id=c58071cb9d14e595",
"/chunks/app-setup.js": "/chunks/app-setup.js?id=ad92e971daa0f86d",
"/chunks/admin-account.js": "/chunks/admin-account.js?id=286b9872565b5e96",
"/chunks/shared.js": "/chunks/shared.js?id=584d7de11142b545",
"/chunks/shared/browser.js": "/chunks/shared/browser.js?id=4722af71c3c7bba6",
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=f60d6a95bc180df2",
"/chunks/shared.js": "/chunks/shared.js?id=e777e8e40fdc11a0",
"/chunks/shared/browser.js": "/chunks/shared/browser.js?id=ca4620238e883070",
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=3af02b5d9d4da341",
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=92c75a6c77689046",
"/chunks/not-found.js": "/chunks/not-found.js?id=36763aa314e00327",
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=a3906226272982b1",
"/chunks/admin.js": "/chunks/admin.js?id=ef7899e0b2be05ce",
"/chunks/admin.js": "/chunks/admin.js?id=dfda0fb3e01450de",
"/chunks/dashboard.js": "/chunks/dashboard.js?id=e7c6001687e641eb",
"/chunks/invoices.js": "/chunks/invoices.js?id=85fd4514d3d85a71",
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=9f970bdfc7583080",
@@ -57,18 +57,18 @@
"/chunks/sign-up.js": "/chunks/sign-up.js?id=098d7f41b85066bf",
"/chunks/forgotten-password.js": "/chunks/forgotten-password.js?id=d6193ed0b07e7957",
"/chunks/create-new-password.js": "/chunks/create-new-password.js?id=d00212636148a14b",
"/chunks/settings.js": "/chunks/settings.js?id=d9518fbb552ac463",
"/chunks/settings.js": "/chunks/settings.js?id=fa7076424e651555",
"/chunks/profile.js": "/chunks/profile.js?id=1217f457145491ec",
"/chunks/settings-password.js": "/chunks/settings-password.js?id=b6704f4cbf14c67d",
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=90ba712f3728443b",
"/chunks/billing.js": "/chunks/billing.js?id=27957f2477fdd121",
"/chunks/platform.js": "/chunks/platform.js?id=325cef5142b27700",
"/chunks/files.js": "/chunks/files.js?id=0d4e7a1330328eae",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=2362f8fa4e3392e9",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=25e9d29dd3c29338",
"/chunks/trash.js": "/chunks/trash.js?id=5bc0e04ada660232",
"/chunks/team-folders.js": "/chunks/team-folders.js?id=cf60b121819ca1a5",
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=bdbbd7e2225a6db9",
"/chunks/platform.js": "/chunks/platform.js?id=863924b804b662c2",
"/chunks/files.js": "/chunks/files.js?id=823d196884eda435",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=72d3b7d6c875f671",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=19b49de44403b4be",
"/chunks/trash.js": "/chunks/trash.js?id=2a7999f7c6ba14cd",
"/chunks/team-folders.js": "/chunks/team-folders.js?id=b8c53410effac0d0",
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=47b3d9874299d8cb",
"/chunks/invitation.js": "/chunks/invitation.js?id=e3f3c2e3501c5a63",
"/css/tailwind.css": "/css/tailwind.css",
"/css/app.css": "/css/app.css"

View File

@@ -16,13 +16,15 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
import Echo from 'laravel-echo';
// window.Pusher = require('pusher-js');
window.Pusher = require('pusher-js');
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: process.env.MIX_PUSHER_APP_KEY,
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
// forceTLS: true
// });
// TODO: set wshost
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'local',
wsHost: '192.168.1.112',
wsPort: 6001,
forceTLS: false
});

View File

@@ -3,6 +3,7 @@ import Vue from 'vue'
import uploadRequest from './modules/uploadRequest'
import fileFunctions from './modules/fileFunctions'
import broadcasting from './modules/broadcasting'
import fileBrowser from './modules/fileBrowser'
import payments from './modules/payments'
import userAuth from './modules/userAuth'
@@ -17,6 +18,7 @@ export default new Vuex.Store({
modules: {
uploadRequest,
fileFunctions,
broadcasting,
fileBrowser,
payments,
userAuth,

View File

@@ -0,0 +1,32 @@
const defaultState = {
isRunningConnection: false,
}
const actions = {
runConnection: ({ commit, getters }) => {
commit('SET_RUNNING_COMMUNICATION')
Echo.private(`test.${getters.user.data.id}`)
.listen('.Domain\\Notifications\\Events\\TestUpdate', (e) => {
console.log(e);
});
},
}
const mutations = {
SET_RUNNING_COMMUNICATION(state) {
state.isRunningConnection = true
},
}
const getters = {
isRunningConnection: (state) => state.isRunningConnection,
}
export default {
state: defaultState,
getters,
actions,
mutations,
}

View File

@@ -10,7 +10,7 @@ const defaultState = {
}
const actions = {
getAppData: ({ commit, getters }) => {
getAppData: ({ commit, getters, dispatch }) => {
return new Promise((resolve, reject) => {
axios
.get(getters.api + '/user' + getters.sorting.URI)
@@ -18,6 +18,10 @@ const actions = {
resolve(response)
commit('RETRIEVE_USER', response.data)
if (! getters.isRunningConnection) {
dispatch('runConnection')
}
})
.catch((error) => {
reject(error)

View File

@@ -11,4 +11,8 @@
|
*/
Broadcast::channel('App.User.{id}', fn ($user, $id) => (int) $user->id === (int) $id);
//Broadcast::channel('App.User.{id}', fn ($user, $id) => (int) $user->id === (int) $id);
Broadcast::channel('test.{id}', function ($user, $id) {
return true;
});

View File

@@ -0,0 +1,18 @@
<?php
namespace Domain\Notifications\Events;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
class TestUpdate implements ShouldBroadcast
{
public string $test = 'I am tru man';
use Dispatchable;
public function broadcastOn(): PrivateChannel
{
return new PrivateChannel('test.6474ef97-472b-43f3-b607-f71df9d33e43');
}
}