Hello there,
I'm trying to setup websockets for my scheduler pro. I'm using the following stack:
Backend
Laravel Framework
Socket server
Laravel Reverb
Frontend
Vue 3
Laravel Echo (for receiving updates from the socket server)
So here is my setup
project: {
eventStore: {
createUrl: '/print-planning/events/create',
readUrl: '/print-planning/events/read',
updateUrl: '/print-planning/events/update',
deleteUrl: '/print-planning/events/delete',
autoCommit: true,
autoLoad: true,
singleAssignment: true
}
}
This is my listener for sending data to the clients. This is event is triggered when an event is succesfully added to the database using the backend.
window.Echo.channel('PrintPlanningEvents').listen('.addEvent', (e) => {
if (this.supports(e, user)) {
scheduler.eventStore.add({
type: e.type,
startDate: e.startDate,
resourceId: e.resourceId,
duration: e.duration,
name: e.name,
_source: 'websocket'
});
}
});
Now what i'm trying to accomplish here is that it adds the event to the clients. Of course that doesn't work in this configuration, because autoCommit is set to true, which results in an endless loop... Is there some way to fix this?? To for example, supress the autoCommit behaviour.
A note should be added here, that i can set autCommit to false, then i would have to do the commits manually, i tried this by adding a addconfirmed listener, and comitting in the listener. But when i do this and i want to create a new record on the side where the event was just added, 2 events will be created on the other clients and i want to add the one i just created.
So my actual question is, what would be a good approach to create events (which are already in the databse because some client created it) and add them to the schedulers of clients which don't have them yet.
Kind regards,
Probo