0.0.0 โข Published 17 days ago
sparrow-rtc v0.0.0
๐ฆ sparrow-rtc
webrtc signalling server, and connections library
๐ฆ npm install sparrow-rtc
๐ live demo: https://sparrow-demo.benevolent.games/
๐ก easily establish webrtc connections and transmit data
๐น๏ธ provides multiplayer game connectivity for https://benevolent.games/
๐ ๏ธ we run the signalling server free at wss://sparrow-rtc.benevolent.games/
๐งช early alpha software, expect changes
๐ free and open source just for you
start a webrtc session as a host
import {createSessionAsHost, standardRtcConfig} from "sparrow-rtc"
const hostConnection = await createSessionAsHost({
label: "my game session",
signalServerUrl: "wss://sparrow-rtc.benevolent.games/",
rtcConfig: standardRtcConfig,
onStateChange({session}) {
console.log("session state changed:", session)
},
handleJoin({clientId, send, close}) {
console.log(`client has joined: ${clientId}`)
send("we can send any string or arraybuffer data!")
// we can close the connection whenever we want
setTimeout(close, 10_000)
return {
handleMessage(message) {
console.log("message received!", message)
},
handleClose() {
console.log("client connection closed:", clientId)
},
}
},
})
console.log(`now hosting session:`, hostConnection.state.sessionId)
connect to a webrtc session as a client
import {joinSessionAsClient, standardRtcConfig} from "sparrow-rtc"
const clientConnection = await joinSessionAsClient({
sessionId: "840ead63", // maybe from an invite link!
signalServerUrl: "wss://sparrow-rtc.benevolent.games/",
rtcConfig: standardRtcConfig,
onStateChange({clientId, session}) {
console.log("state changed", {clientId, session})
},
handleJoin({clientId, send, close}) {
console.log(`client has joined: ${clientId}`)
send("we can send any string or arraybuffer data!")
// we can close the connection whenever we want
setTimeout(close, 10_000)
return {
handleMessage(message) {
console.log("message received!", message)
},
handleClose() {
console.log("client connection closed:", clientId)
},
}
}
})
console.log(`now connected as client to session:`, clientConnection.state.session)
run your own instance of the signalling server
we are running a free instance of the signalling server at this websocket endpoint:
wss://sparrow-rtc.benevolent.games/
but if you'd like to run your own instance of the signalling server,
you can clone this repo, and then
npm install
to install dependenciesnpm run build
to build the projectnpm run start-signal-server 8080
to run the signalling server on port 8080
0.0.0
17 days ago
0.0.0-dev.7
1 month ago
0.0.0-dev.6
2 years ago
0.0.0-dev.5
2 years ago
0.0.0-dev.4
2 years ago
0.0.0-dev.3
2 years ago
0.0.0-dev.2
2 years ago
0.0.0-dev.1
2 years ago
0.0.0-dev.0
2 years ago