websocket implementation

This commit is contained in:
Čarodej
2022-03-09 07:40:05 +01:00
parent 2a0b01e888
commit 8495ed5422
15 changed files with 1816 additions and 226 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",

1602
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');
}
}

31
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",
@@ -8653,14 +8676,6 @@
"vue-style-loader": "^4.1.0"
}
},
"vue-paystack": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/vue-paystack/-/vue-paystack-2.0.4.tgz",
"integrity": "sha512-EwIvuWpQ5MuvKjqv3AZ0NqHdFHZrUGynUn6aCAi1pj62mazBCVUZk/I0ISnPKVIM39weUUUIDUEXIKhJcezT7w==",
"requires": {
"vue": "^2.6.7"
}
},
"vue-recaptcha-v3": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/vue-recaptcha-v3/-/vue-recaptcha-v3-1.9.0.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,75 +1,75 @@
{
"/js/main.js": "/js/main.js",
"/chunks/request.js": "/chunks/request.js?id=f0d2c08b78353759",
"/chunks/request-upload.js": "/chunks/request-upload.js?id=8158aa32cc0e7810",
"/chunks/setup-wizard.js": "/chunks/setup-wizard.js?id=3c2fc454c3fce8d2",
"/chunks/status-check.js": "/chunks/status-check.js?id=1ce085bce8a9e959",
"/chunks/purchase-code.js": "/chunks/purchase-code.js?id=957577e6eb9bae5d",
"/chunks/database.js": "/chunks/database.js?id=cd8195615624bf64",
"/chunks/environment-setup.js": "/chunks/environment-setup.js?id=1153d1ccda1626d3",
"/chunks/app-setup.js": "/chunks/app-setup.js?id=8f3130f31073813a",
"/chunks/admin-account.js": "/chunks/admin-account.js?id=3ca1c2c54a26a225",
"/chunks/shared.js": "/chunks/shared.js?id=fa9e99015d34f4ee",
"/chunks/shared/browser.js": "/chunks/shared/browser.js?id=dbef35b6141563d5",
"/chunks/shared/single-file.js": "/chunks/shared/single-file.js?id=4316b3f869e011da",
"/chunks/shared/authenticate.js": "/chunks/shared/authenticate.js?id=dc1a48627066c81d",
"/chunks/not-found.js": "/chunks/not-found.js?id=026c52609cff0249",
"/chunks/temporary-unavailable.js": "/chunks/temporary-unavailable.js?id=250d923cb7001cf2",
"/chunks/admin.js": "/chunks/admin.js?id=9e533336111a20e0",
"/chunks/dashboard.js": "/chunks/dashboard.js?id=94dfb7c678309b6e",
"/chunks/invoices.js": "/chunks/invoices.js?id=0817b6e71b0da736",
"/chunks/subscriptions.js": "/chunks/subscriptions.js?id=aa4ca6695a4c43f2",
"/chunks/pages.js": "/chunks/pages.js?id=b18e753a266e4d6e",
"/chunks/page-edit.js": "/chunks/page-edit.js?id=0122891b250ee8c7",
"/chunks/plans.js": "/chunks/plans.js?id=8950c28ea8d9273d",
"/chunks/users.js": "/chunks/users.js?id=16f7770d2b8a7043",
"/chunks/user-create.js": "/chunks/user-create.js?id=5b1f7e752521c02a",
"/chunks/plan-create/fixed.js": "/chunks/plan-create/fixed.js?id=44bbf94f2267d262",
"/chunks/plan-create/metered.js": "/chunks/plan-create/metered.js?id=cfb50d511c78ec04",
"/chunks/user.js": "/chunks/user.js?id=c12de27dc40aef36",
"/chunks/user-detail.js": "/chunks/user-detail.js?id=3c2bbf0a6ef97c1c",
"/chunks/user-storage.js": "/chunks/user-storage.js?id=e5c9e1b59264172a",
"/chunks/user-subscription.js": "/chunks/user-subscription.js?id=21154e4250e890b3",
"/chunks/user-password.js": "/chunks/user-password.js?id=d6d72d8a0f08cac4",
"/chunks/user-delete.js": "/chunks/user-delete.js?id=b95a20df2fd09190",
"/chunks/plan.js": "/chunks/plan.js?id=2444730c1a0a42fc",
"/chunks/plan-subscribers.js": "/chunks/plan-subscribers.js?id=f75a62dc82dfd06d",
"/chunks/plan-settings.js": "/chunks/plan-settings.js?id=889139d2e1679331",
"/chunks/plan-delete.js": "/chunks/plan-delete.js?id=14cb6e7146563c8c",
"/chunks/payments.js": "/chunks/payments.js?id=5ea275fedd8d638a",
"/chunks/payments/billings.js": "/chunks/payments/billings.js?id=a0757d9c2608d7ad",
"/chunks/payments/settings.js": "/chunks/payments/settings.js?id=09b5ed53c184aefc",
"/chunks/app-settings.js": "/chunks/app-settings.js?id=b0ca7cdad56e46fd",
"/chunks/app-appearance.js": "/chunks/app-appearance.js?id=47f92b72e275c2c8",
"/chunks/app-index.js": "/chunks/app-index.js?id=6255a58886c31bc6",
"/chunks/app-environment.js": "/chunks/app-environment.js?id=9d37862ac5c57c1e",
"/chunks/app-others.js": "/chunks/app-others.js?id=918ccb0a9edff971",
"/chunks/app-sign-in-out.js": "/chunks/app-sign-in-out.js?id=9e6099c710a1f774",
"/chunks/app-adsense.js": "/chunks/app-adsense.js?id=ce66e5cd4d33b77f",
"/chunks/app-server.js": "/chunks/app-server.js?id=000b75779c7b2df7",
"/chunks/app-language.js": "/chunks/app-language.js?id=9fea501b5651db74",
"/chunks/homepage.js": "/chunks/homepage.js?id=cc55de7273bd9699",
"/chunks/dynamic-page.js": "/chunks/dynamic-page.js?id=a20e623585f77df6",
"/chunks/contact-us.js": "/chunks/contact-us.js?id=5d02f74ec520ae00",
"/chunks/successfully-email-verified.js": "/chunks/successfully-email-verified.js?id=cadce663beaa7f88",
"/chunks/successfully-email-send.js": "/chunks/successfully-email-send.js?id=f14b81ce738531a5",
"/chunks/sign-in.js": "/chunks/sign-in.js?id=5d8ffa33a3b2ef19",
"/chunks/sign-up.js": "/chunks/sign-up.js?id=7ef0f23926cf5303",
"/chunks/forgotten-password.js": "/chunks/forgotten-password.js?id=283220c4946806d4",
"/chunks/create-new-password.js": "/chunks/create-new-password.js?id=59775b0f2612479a",
"/chunks/settings.js": "/chunks/settings.js?id=d62afe6801587c47",
"/chunks/profile.js": "/chunks/profile.js?id=ec621bd75eada0ee",
"/chunks/settings-password.js": "/chunks/settings-password.js?id=3e094b17498f56df",
"/chunks/settings-storage.js": "/chunks/settings-storage.js?id=cddf4c1f69a29992",
"/chunks/billing.js": "/chunks/billing.js?id=9a21ec44813c1ac7",
"/chunks/platform.js": "/chunks/platform.js?id=3a47c4d793d2336d",
"/chunks/files.js": "/chunks/files.js?id=f15d5466e064d948",
"/chunks/recent-uploads.js": "/chunks/recent-uploads.js?id=73a66aeaf04095fe",
"/chunks/my-shared-items.js": "/chunks/my-shared-items.js?id=27e3e0fcf0ddc4b1",
"/chunks/trash.js": "/chunks/trash.js?id=fbe62ce340ffc821",
"/chunks/team-folders.js": "/chunks/team-folders.js?id=562bc2bc53af84dd",
"/chunks/shared-with-me.js": "/chunks/shared-with-me.js?id=5ffd2add7c7535dc",
"/chunks/invitation.js": "/chunks/invitation.js?id=4884f1794da246a6",
"/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",
"/chunks/database.js": "/chunks/database.js?id=d5695176ac8edfb9",
"/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=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=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",
"/chunks/pages.js": "/chunks/pages.js?id=38c76f5552161514",
"/chunks/page-edit.js": "/chunks/page-edit.js?id=dbdaf49f7c709ab9",
"/chunks/plans.js": "/chunks/plans.js?id=b5e1384c6e697927",
"/chunks/users.js": "/chunks/users.js?id=8ea54582b0ccd769",
"/chunks/user-create.js": "/chunks/user-create.js?id=c620606ec7eef9d7",
"/chunks/plan-create/fixed.js": "/chunks/plan-create/fixed.js?id=5515d5a19259eadf",
"/chunks/plan-create/metered.js": "/chunks/plan-create/metered.js?id=94d6ef85f6a58265",
"/chunks/user.js": "/chunks/user.js?id=879268a26e94d198",
"/chunks/user-detail.js": "/chunks/user-detail.js?id=4b171a846c808667",
"/chunks/user-storage.js": "/chunks/user-storage.js?id=835667dbe1fdf9b1",
"/chunks/user-subscription.js": "/chunks/user-subscription.js?id=cf39975217b4e268",
"/chunks/user-password.js": "/chunks/user-password.js?id=41e945a8e10bd4e4",
"/chunks/user-delete.js": "/chunks/user-delete.js?id=2184dc78049878ec",
"/chunks/plan.js": "/chunks/plan.js?id=37a04161ac1973ad",
"/chunks/plan-subscribers.js": "/chunks/plan-subscribers.js?id=5c4c760ab08a59c6",
"/chunks/plan-settings.js": "/chunks/plan-settings.js?id=b1d3ffbb79e69310",
"/chunks/plan-delete.js": "/chunks/plan-delete.js?id=4e9d13b048f1d8f0",
"/chunks/payments.js": "/chunks/payments.js?id=2a6dba57de536b0d",
"/chunks/payments/billings.js": "/chunks/payments/billings.js?id=e8f23f4fb51d2bb2",
"/chunks/payments/settings.js": "/chunks/payments/settings.js?id=4e3da3de7b57a89a",
"/chunks/app-settings.js": "/chunks/app-settings.js?id=ac94675bfea2ac48",
"/chunks/app-appearance.js": "/chunks/app-appearance.js?id=19980ab8fd75125c",
"/chunks/app-index.js": "/chunks/app-index.js?id=d1722a2c5d30b142",
"/chunks/app-environment.js": "/chunks/app-environment.js?id=7018c929bffb3a78",
"/chunks/app-others.js": "/chunks/app-others.js?id=ecbfebacc4f269cb",
"/chunks/app-sign-in-out.js": "/chunks/app-sign-in-out.js?id=11df2ce06e785892",
"/chunks/app-adsense.js": "/chunks/app-adsense.js?id=ec2fa21b02c99cb9",
"/chunks/app-server.js": "/chunks/app-server.js?id=8964b98aee4cca69",
"/chunks/app-language.js": "/chunks/app-language.js?id=2ae6285274dacd0d",
"/chunks/homepage.js": "/chunks/homepage.js?id=1b595dee57a8f161",
"/chunks/dynamic-page.js": "/chunks/dynamic-page.js?id=f8c67b2a376ff03e",
"/chunks/contact-us.js": "/chunks/contact-us.js?id=3c7d7bba5e7fc172",
"/chunks/successfully-email-verified.js": "/chunks/successfully-email-verified.js?id=261b02aed36069be",
"/chunks/successfully-email-send.js": "/chunks/successfully-email-send.js?id=fe054c1e34d7863b",
"/chunks/sign-in.js": "/chunks/sign-in.js?id=115555a1dd6fea58",
"/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=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=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');
}
}