Something went wrong. Try again.
a demonstration replicated social networking web app built with anproto wiredove.net
social ed25519 protocols
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import { apds } from 'apds'import { joinRoom } from './trystero-torrent.min.js'import { render } from './render.js'
export let chan
export const sendTry = (m) => { if (chan) { if (m.length === 44) { chan.sendHash(m)} else { chan.sendBlob(m) } } else { setTimeout(() => {sendTry(m)}, 1000) }}
export const makeRoom = async (pubkey) => { if (!chan) { const room = joinRoom({appId: 'wiredovetestnet', password: 'iajwoiejfaowiejfoiwajfe'}, pubkey) const [ sendHash, onHash ] = room.makeAction('hash') const [ sendBlob, onBlob ] = room.makeAction('blob')
room.sendHash = sendHash room.sendBlob = sendBlob
onHash(async (hash, id) => { console.log(`Received: ${hash}`) const get = await apds.get(hash) if (get) { sendBlob(get, id)} const latest = await apds.getLatest(hash) if (latest) { sendBlob(latest.sig)} })
onBlob(async (blob, id) => { console.log(`Received: ${blob}`) //await process(blob) <-- trystero and ws should use the same process function await apds.make(blob) await render.shouldWe(blob) await apds.add(blob) await render.blob(blob) })
room.onPeerJoin(async (id) => { console.log(id + ' joined the room ' + pubkey) const latest = await apds.getLatest(await apds.pubkey()) if (latest) { sendblob(latest.sig) } })
room.onPeerLeave(id => { console.log(id + ' left the room ' + pubkey) })
chan = room }}