Skip to content

Instantly share code, notes, and snippets.

@emschwartz
Created May 18, 2018 04:05
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save emschwartz/26fba565595f119b95e95f4818798613 to your computer and use it in GitHub Desktop.
STREAM Client Snippet
const clientPlugin = createPlugin()
const clientConn = await IlpStream.createConnection({
plugin: clientPlugin,
destinationAccount,
sharedSecret
})
// Streams are automatically given ids (client-initiated ones are odd, server-initiated are even)
const streamA = clientConn.createStream()
const streamB = clientConn.createStream()
console.log(`sending data to server on stream ${streamA.id}`)
streamA.write('hello there!')
console.log(`sending data to server on stream ${streamB.id}`)
streamB.write('hello there!')
console.log(`sending money to server on stream ${streamA.id}`)
await streamA.sendTotal(100)
console.log('sent 100 units')
console.log(`sending money to server on stream ${streamB.id}`)
await streamB.sendTotal(200)
console.log('sent 200 units')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment