antoniodipinto / ikisocket

🧬 WebSocket wrapper with event management for Fiber https://github.com/gofiber/fiber. Based on Fiber WebSocket and inspired by Socket.io
MIT License
123 stars 21 forks source link

(Question) How to send message from an outside ikisocket code? #16

Closed alvesoaj closed 2 years ago

alvesoaj commented 3 years ago

Thanks for this package.

I have one application that uses Gorm to deal with database models, and in there there are callbacks like BeforeCreate or AfterSave...

My question is, how to emit ou send messages from inside these callbacks, or even from regular Fiber endpoints?

Do ikisocket public/global functions do this kind of job?

antoniodipinto commented 3 years ago

Hi,

If I understand correctly your question, yes, public functions will help you achieve this. Just remember the fact that you still need to have the ID of the socket to send messages to a specific client.

Thank you for you support :)

alvesoaj commented 3 years ago

Thanks, @antoniodipinto, I will use Redis to store the IDs. When I finish it I will back here and tell the story.