frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Building CallSpark (browser based VoIP): what I learned and what caused pain

1•ahmaliic•33m ago
I’ve been building CallSpark, a browser-based calling platform. The core VoIP flow through Twilio’s browser SDK worked as advertised. The hard parts were elsewhere.

The easy part

Twilio’s SDK was straightforward. Initialize a Device, pass in a token, call connect. WebRTC and audio quality held up without much tuning.

The real problems

1. Call state inside the browser The SDK emits events at the right times, but React state doesn’t always represent what the call is actually doing. UI components mount, unmount, or re-render, and state drifts. I wanted the call to remain online even if the user goes to any other page in-app. A call may still be active while the UI falsely thinks it’s disconnected, or vice versa.

I ended up keeping a global reference to the active call and broadcasting custom events so every component could stay aligned. It’s not elegant, but it’s the only approach that consistently kept the UI accurate.

Twilio also doesn’t provide a reliable “call started” timestamp, so I track it myself but obviously I can't use it for billing.

2. Real-time billing I wanted per-second (or per minute) billing while the call is active. Twilio’s post-call webhook isn’t useful for real-time checks because it arrives only after the call finishes. And it does not always contains the call cost.

My backend runs a periodic worker that finds active calls, computes how much time has passed since the last charge, deducts credits, and ends the call if the user runs out of balance. This part works, but you quickly run into edge cases.

If the worker misses a cycle, you have to reconcile without double-charging.. The browser UI might vanish, but billing and call state must continue accurately.

The solution I found was partial billing (roast me on this if you want). A worker runs every ten seconds and looks at all active calls. If the user has enough balance to cover the next ten seconds, the call continues. If not, it ends. After each interval, the worker reserves the cost for the previous ten seconds. When the call ends, twilio tells us with webhook, and I reconcile how much I debited from credits, how much must actually be debited etc etc.

What I’m still solving

A better pattern for keeping client-side call state aligned without falling back to global objects.

A clean way to handle situations where the browser UI disappears mid-call but the call itself continues normally on the backend.

Questions for the community

> If you’ve built real-time billing for VoIP, how did you structure it. > How did you maintain accurate browser UI state for long-lived calls. > Any lessons from working with Twilio’s browser SDK.

Are Modern Droughts Unprecedented?

https://essopenarchive.org/doi/full/10.22541/essoar.176384963.31728350/v1
2•bikenaga•22s ago•0 comments

Buildsheet.one – Create Beautiful Cheatsheets

https://buildsheet.one
1•usegrand•26s ago•0 comments

Opus 4.5

https://twitter.com/claudeai/status/1993030546243699119
2•incoming1211•28s ago•0 comments

NASA confirms that Starliner's next mission will be cargo only

https://arstechnica.com/space/2025/11/nasa-confirms-that-starliners-next-mission-will-be-cargo-only/
1•Bender•58s ago•0 comments

Opus 4.5

https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-5
5•p0seidon•3m ago•0 comments

Claude Opus 4.5

https://www.anthropic.com/news/claude-opus-4-5
9•adocomplete•3m ago•0 comments

Pebble Watch Software Is Now 100% Open Source

https://ericmigi.com/blog/pebble-watch-software-is-now-100percent-open-source
2•Larrikin•4m ago•0 comments

Google's new 'Aluminium OS' project brings Android to PC

https://www.androidauthority.com/aluminium-os-android-for-pcs-3619092/
4•jmsflknr•6m ago•0 comments

Google experts tell the US DOJ selling its ad tech business would be impossible

https://www.androidcentral.com/apps-software/google-experts-tell-the-us-doj-selling-its-ad-tech-b...
2•01-_-•7m ago•0 comments

Show HN: New Systems Programming Language with Builtin Parallelism and No GC

https://axelang.org/
2•death_eternal•7m ago•0 comments

Steam Next Fest's Breakout Only Requires a Fraction of Your Screen and Attention

https://kotaku.com/steam-next-fests-most-unlikely-breakout-only-requires-a-fraction-of-your-scree...
1•PaulHoule•7m ago•0 comments

GrapheneOS migrates server infrastructure from France

https://www.privacyguides.org/news/2025/11/22/grapheneos-migrates-server-infrastructure-from-fran...
5•01-_-•8m ago•2 comments

UX Patterns for Artificial Intelligence Design

https://www.shapeof.ai
1•aratahikaru5•9m ago•0 comments

MoreMinds: Every Idea Becomes a Startup

https://moreminds.ai
1•jroseborough•9m ago•2 comments

Is Your Android TV Streaming Box Part of a Botnet?

https://krebsonsecurity.com/2025/11/is-your-android-tv-streaming-box-part-of-a-botnet/
5•todsacerdoti•9m ago•0 comments

How AI Bubble Can Burst

https://heyvk.substack.com/p/how-ai-bubble-can-actually-burst
1•thatoneguytoo•10m ago•0 comments

Self-hosting your static assets or any piece of media

https://mighil.com/on-self-hosting-your-static-assets-or-any-piece-of-media
1•speckx•11m ago•0 comments

Should You Be Worried About a Tiny Black Hole Hitting Your Body?

https://gizmodo.com/should-you-be-worried-about-a-tiny-black-hole-hitting-your-body-2000690695
1•ulrischa•11m ago•0 comments

How to Secure the Boot Chain

https://blog.velocifyer.com/Posts/6,2025+10+23,%20How%20to%20secure%20the%20entire%20boot%20chain...
1•Velocifyer•11m ago•0 comments

An Intelligence Platform to Systematically Exploit Polymarket Inefficiencies

https://polytools.market
1•idogrady•11m ago•1 comments

People who self report as lonely also report as political [video]

https://youtube.com/shorts/2E7khK8MBeQ?si=uoJGzzhSEY1ySQ6W
1•lifeisstillgood•12m ago•1 comments

Understanding the limitations of pubsub systems [pdf]

https://sigops.org/s/conferences/hotos/2025/papers/hotos25-426.pdf
1•mbj111•12m ago•1 comments

Norway's lesson for Europe on wealth taxes: let some millionaires go

https://www.reuters.com/business/norways-wealth-tax-trades-millionaires-equality-2025-11-24/
3•wslh•13m ago•0 comments

Analog Hoverboard Controller

https://github.com/skrubis/analog-hoverboard
1•skrubis•14m ago•0 comments

Source code linking in C2Rust: merging C headers into Rust modules

https://immunant.com/blog/2019/12/header_merging/
1•fanf2•14m ago•0 comments

NATO taps Google for air-gapped sovereign cloud

https://www.theregister.com/2025/11/24/nato_google_cloud/
1•naves•15m ago•0 comments

One in two people in the US is affected by a neurological disease or disorder

https://medicalxpress.com/news/2025-11-people-affected-neurological-disease-disorder.html
3•bikenaga•16m ago•0 comments

Show HN: Runbooks – Shareable Claude Code Sessions

https://www.aviator.co/runbooks
2•ankitdce•17m ago•0 comments

Launch HN: Karumi (YC F25) – Personalized, agentic product demos

https://www.karumi.ai/meet/start/phlz
3•tonilopezmr•19m ago•0 comments

Hollywood's dark era: where did all the colour from movies go?

https://www.theguardian.com/film/2025/nov/24/hollywood-dark-era-colour-in-movies-wicked
3•devonnull•19m ago•0 comments