Docs ยท 0.26.0
Upgrading to 0.26
Version 0.26 adds receive approval and a default receive budget, improves reconnection, and reduces idle resource use. Two changes need attention before you upgrade.
Upgrade peers together
The internal action wire format changed in 0.26. Upgrade all clients that communicate with each other, including server-side peers. Plan how to refresh old browser tabs; peers on older versions cannot be assumed to exchange actions with 0.26 clients.
Incoming payloads now default to a 256 MiB limit per
room, which also budgets concurrent large transfers. If your app receives
larger files, raise maxReceiveBytes on the receiving peers.
Files must still fit in memory. See
receive budgets and
onReceive approval.
If you are coming from before 0.25
makeAction() returns an action object. Replace tuple
destructuring such as [send, receive, progress] with
action.send(), action.onMessage, and
action.onReceiveProgress. Receiver callbacks take a context
object as their second argument.
const chat = room.makeAction('chat')
chat.send({text: 'hello'}, {target: peerId})
chat.onMessage = (message, {peerId, metadata}) => {
addMessage(peerId, message)
}Room event handlers are callback properties rather than registration functions. Media methods take an options object for targeting and, when adding or replacing media, metadata.
room.onPeerJoin = peerId => showPeer(peerId)
room.onPeerLeave = peerId => removePeer(peerId)
room.onPeerStream = (stream, peerId, metadata) => {
attachStream(peerId, stream, metadata)
}
room.addStream(localStream, {
target: peerId,
metadata: {kind: 'camera'}
})
For code from before 0.24, move relay settings under
relayConfig. For example, use
relayConfig.urls and relayConfig.redundancy.
Install the separate @trystero-p2p/* package for any strategy
you use beyond the default Nostr package.