Comments (4)
Connections must be made from a web process since the scheduler process does not run a web server.
I suggest using something like Redis to send a message from the scheduler process(es) to the web process(es). Then, the web process can send a websocket message to the client.
https://adonisjs.com/docs/4.1/redis#_pub_sub
from adonis-scheduler.
You can try use AdonisJS Events for send event to WS.
I use it in adonis version 3.2
from adonis-scheduler.
Hi @ntvsx193, could you explain more about what was your approach to send event to WS? I tried using AdonisJS Events too when initializing the socket and but keep getting undefined when I want to broadcast the message, even after the initialization happened.
// start/events.js
Event.on('cardPrice::initialize', (socket) => {
wsSocket = socket;
console.log('wsSocket', wsSocket);
});
Event.on('cardPrice::update', async (newCardPriceList) => {
console.log('wsSocket update', wsSocket); << keep getting undefined even after initialize happened
});
// app/Controller/WS/UpdateCardPriceController.js
class UpdateCardPriceController {
constructor({socket, request}) {
this.socket = socket;
this.request = request;
Event.fire('cardPrice::initialize', socket);
console.log('a new subscription for cardPrice topic');
}
}
from adonis-scheduler.
@AudyOdi
I been have this Issues too while I trying to make a database connect in WebSocketController
I been thinking in maybe making a service provider and using is I can over this stack
from adonis-scheduler.
Related Issues (20)
- Which version is valid for Adonis 3.2? HOT 3
- error: `make:task` is not a registered command HOT 16
- Non-js files are picked up by the run:schedule command HOT 1
- Run schedules without the ./ace command HOT 2
- call task in the project not from terminal HOT 1
- Cannot use Adonis Logger provider in Task HOT 2
- Make sure CommandsProvider extends the base command HOT 2
- AdonisJs CronJobs HOT 1
- Cannot run migration HOT 1
- Thanks @hoangmy92, that is what I would recommend. HOT 3
- Data type error in the population of the logs HOT 1
- Cannot Load Tasks In Subdirectory HOT 6
- E_INVALID_SERVICE_PROVIDER: SchedulerProvider must extend base service provider class
- How to exit the cron job when an error occurs? HOT 1
- Is it possible to run every 30 seconds? HOT 1
- timezone different in server HOT 1
- As wheels in production? HOT 2
- Is Adonis-Scheduler still maintained?
- How do I set this package up on Heroku?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adonis-scheduler.