@agoric/captp
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -232,2 +232,6 @@ // This logic was mostly lifted from @agoric/swingset-vat liveSlots.js | ||
// Abort a connection. | ||
const abort = exception => | ||
dispatch({ type: 'CTP_ABORT', exception }); | ||
// Return a dispatch function. | ||
@@ -246,3 +250,3 @@ const dispatch = obj => { | ||
return harden({ dispatch, getBootstrap }); | ||
return harden({ abort, dispatch, getBootstrap }); | ||
} |
{ | ||
"name": "@agoric/captp", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Capability Transfer Protocol for distributed objects", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,13 +7,20 @@ # `@agoric/captp` | ||
``` | ||
import makeCapTP from '@agoric/captp'; | ||
import { E } from '@agoric/eventual-send'; | ||
NOTE: `myconn` below is not part of the CapTP library, it represents a connection | ||
object that you have created where `makeCapTP` is called on both sides of the | ||
connection, passing in the function to send a JSON-able object on the connection, and returning | ||
a `dispatch` function to receive a decoded JSON object from the connection. | ||
// Create a message handler and bootstrap. | ||
```js | ||
import { E, makeCapTP } from '@agoric/captp'; | ||
// Create a message dispatcher and bootstrap. | ||
// Messages on myconn are exchanged with JSON-able objects. | ||
const [handler, getBootstrap] = makeCapTP('myid', myconn.send, myBootstrap); | ||
myconn.onReceive = obj => handler[obj.type](obj); | ||
const { dispatch, getBootstrap, abort } = makeCapTP('myid', myconn.send, myBootstrap); | ||
myconn.onReceive = obj => dispatch(obj); | ||
// Get the remote's bootstrap object and call a remote method. | ||
E(getBootstrap()).method(args).then(res => console.log('got res', res)); | ||
// Tear down the CapTP connection if it fails (e.g. connection is closed). | ||
abort(Error('Connection aborted by user.')); | ||
``` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
288277
8165
26