I am working on some ionic app where laravel is used for api's . There is some demand on having a real time chat functionality .
I have been trying to use something like socket.io .
SO question is without changing stacks , how can i achieve it . My current stacks are cordova , ionic and then laravel mysql for server side .
can this be achieved with current stack ?
Thanks for the help in advance .
Cheers!
Yes, it can be done with this stack - I've done it myself, and I wrote a blog post about how to do so. The Laravel documentation also goes into some detail about this. Our app wasn't using Ionic, but otherwise the situation was basically the same.
The gist of it is as follows:
NewMessage
eventNewMessage
event, and when it fires, emits the message to all attached clients (or if chat is meant to be private, only the appropriate clients)socket.io-client
, the appropriate action is taken, eg the message is inserted into the DOMThe only addition you need to make to your stack is Node.js and Redis. The biggest issue I had was with configuring Nginx, but that was partly because I was using SSL.
Hope this makes sense. Let me know if you need any more information on how to accomplish this.
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