Created
May 18, 2018 04:05
-
-
Save emschwartz/26fba565595f119b95e95f4818798613 to your computer and use it in GitHub Desktop.
STREAM Client Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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