I have created my rest application in Loopback 4 and now I want to implement socket in it. Is there any way to do so in RestApplication?
export class MyApplication extends BootMixin(
ServiceMixin(RepositoryMixin(RestApplication)),
) {
constructor(
options: ApplicationConfig = {}
) {
super(options);
}
....
async start() {
await super.start();
const io = socketio(this.restServer);
io.on('connection', (socket: any) => {
console.log('connected');
});
}
}
const io = socketio(this.restServer); isn't working for me
Here is a Official Loopback 4 example with socket.io integration. This example is created to explore how to expose Websocket (socket.io) endpoints in conjunction with LoopBack controllers.
https://github.com/raymondfeng/loopback4-example-websocket
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With