-
Notifications
You must be signed in to change notification settings - Fork 158
feat: notifiers support in aries rest client js worker #1372
Conversation
this.socket = new WebSocket(url); | ||
this.socket.addEventListener('message', function (event) { | ||
// TODO REST agents are not currently revealing topic information on incoming messages, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you patch the REST agent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as part of #1323
All BDD tests will fail, so will push it in next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
// TODO REST agents are not currently revealing topic information on incoming messages, | ||
// Once REST supports this feature, topic value will be dynamic. | ||
postMsg(newResponse("random-id", event.data, "", "all")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
random-id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it
} | ||
stop(){ | ||
this.socket.close(1011, "stopped notifier in aries-js-worker") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1011?
can we replace magic number with a named const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you should patch REST agent to not throw a log on 1011 status code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. Isn't 1011 an error code?(https://github.com/nhooyr/websocket/blob/94f9b71576625ef4dbe5950253cbfa8b539b88b5/close.go#L42)
Shouldn't you use a non-error status? Whichever status you use should be updated in REST server to ensure no error log is printed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to normal closure code 1000
@@ -106,7 +106,7 @@ | |||
document.getElementById("mode-label").innerHTML = `Running in ${mode} mode` | |||
|
|||
if (src == "rest"){ | |||
document.getElementById("opts").innerHTML = `{"assetsPath": "/dist/assets", "agent-rest-url": "http://localhost:8082"}` | |||
document.getElementById("opts").innerHTML = `{"assetsPath": "/dist/assets", "agent-rest-url": "http://localhost:8082", "agent-rest-wshook":"ws://localhost:8881"}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rest code called it a notifier rather than a hook. (not sure what is the correct generic term to use.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in agent-rest start command we call it webhook, so reused that term here.
notifier
term is use for "startNotifier/stopNotifier" where we watch for incoming messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at these URLs, I see that we should document somewhere how to properly run this index.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ie. this goes way past just inflating the wasm file. It requires services up and running in addition to the inflated wasm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one other point: can we start using property names with no special characters such that the double quotes aren't needed? Like assetsPath
for instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated docs
This new option requires a line in the docs
193dc14
to
f208fb8
Compare
This new option requires a line in the docs |
f208fb8
to
74d4f84
Compare
- new constructor opts `agent-rest-wshook` in rest client based aries js worker. If provided then `aries.startNotifier` can be used to listen to incoming messages - closes hyperledger-archives#1370 Signed-off-by: sudesh.shetty <sudesh.shetty@securekey.com>
74d4f84
to
e4d0b76
Compare
new constructor opts
agent-rest-wshook
in rest client based aries jsworker. If provided then
aries.startNotifier
can be used to listen toincoming messages
closes Aries Rest Client JS worker - Add websocket notifier #1370
Signed-off-by: sudesh.shetty sudesh.shetty@securekey.com