Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Going real time with donation alerts

Posted on Oct 20 At Alertpix we allow streamers to receive donations from their audience via Pix Instant Payment and show an alert on the live stream.This post shows how donation alerts feature was coded in just a day.Our users can use their Streamlabs account to use their own alert box in the live stream.However, we also have users that don't use Streamlabs, that's where the Notification widget comes in.The ideia was simple: each widget listens into a topic and receives a new alert to show when its not showing any alerts.This new service was bootstrapped with Elysia, the fastest Bun framework.Now, to create a new http server is just as simple as:Now we need to allow for widget to connect via WebSockets:Here is where the tech stack shines. We can allow WebSocket connections, add schema validation to their messages and request params.We can also create a pub sub mechanism with a built-in API in bun.This can be done in a line of code when the socket connects:We also stored the widget in a free list. Meaning that the widget is not currently showing any alerts.When the peer disconnects, we remove it from the list:The widget can send a message telling that its free, so we handle that as well.We check if the topic has items so we send the next alert, if any. Tagging it as free or not:We updated our API to store the notification in the queue and publish to the notifying service via an API call:API call that we defined with the same logic to notify the connected peers if they are free:Choosing the right tech stack helps a lot. But knowing about the topic and understanding what is needed to build the feature, we can build things pretty fast. In this post we show how at AlertPix we code each feature in one hour.Since we launched we improve every day a little bit. Of course, today the implementation is pretty much different than this. But this blog aims to illustrate how you can write a pub sub without fighting against the code.Take a look in the code exampls if it where a complete code so you can try it yourself:AlertPixTemplates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Faith Morante - Oct 18 Sumit Bhanushali - Oct 6 Dumebi Okolo - Oct 18 Sridhar CR - Oct 10 Once suspended, alertpix will not be able to comment or publish posts until their suspension is removed. Once unsuspended, alertpix will be able to comment and publish posts again. Once unpublished, all posts by alertpix will become hidden and only accessible to themselves. If alertpix is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to Christopher Ribeiro. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag alertpix: alertpix consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging alertpix will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Going real time with donation alerts

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×