@vibe-rtc/rtc-core
v0.1.0
Published
Core WebRTC signaling/transport package with reconnect behavior and typed errors.
Downloads
15
Readme
@vibe-rtc/rtc-core
Core WebRTC signaling/transport package with reconnect behavior and typed errors.
Install
pnpm add @vibe-rtc/rtc-coreMain API
RTCSignalerRTCError,RTCErrorCode,toRTCError,isRTCErrorwithDefaultIceServers,DEFAULT_ICE_SERVERSSignalDBinterface for custom signaling backends
SignalDB Contract
Implement SignalDB from src/types.tsx with methods for:
- room lifecycle:
createRoom,joinRoom,getRoom,endRoom - SDP exchange:
getOffer,setOffer,clearOffer,setAnswer,clearAnswer - ICE exchange: add/subscribe for caller/callee candidate streams
- cleanup:
clearCallerCandidates,clearCalleeCandidates
Quick Example
import { RTCSignaler } from '@vibe-rtc/rtc-core'
const signaler = new RTCSignaler('caller', signalDb, {
debug: true,
waitReadyTimeoutMs: 10000,
rtcConfiguration: {
iceServers: [
{ urls: ['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302'] },
],
},
})
const roomId = await signaler.createRoom()
await signaler.joinRoom(roomId)
await signaler.connect()
await signaler.sendReliable('hello')
await signaler.reconnectSoft()
await signaler.reconnectHard({ awaitReadyMs: 15000 })
await signaler.endRoom()Runtime Options
debug: enables internal console logs (console.log/console.error).
By default logs are enabled only in test runtime.waitReadyTimeoutMs: default timeout forwaitReady()andreconnectHard()if no timeout is passed explicitly.rtcConfiguration: optionalRTCPeerConnectionconfig.
If omitted (or ificeServersis empty),rtc-coreinjects default STUN servers.
Error Handling
Use RTCErrorCode for stable UI/test handling:
ROOM_NOT_SELECTEDROOM_NOT_FOUNDAUTH_REQUIREDDB_UNAVAILABLESIGNAL_TIMEOUTWAIT_READY_TIMEOUTSIGNALING_FAILEDINVALID_STATEUNKNOWN
Development
pnpm --filter @vibe-rtc/rtc-core build
pnpm --filter @vibe-rtc/rtc-core test