Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

feat: notifiers support in aries rest client js worker #1372

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

sudeshrshetty
Copy link
Contributor

Signed-off-by: sudesh.shetty sudesh.shetty@securekey.com

this.socket = new WebSocket(url);
this.socket.addEventListener('message', function (event) {
// TODO REST agents are not currently revealing topic information on incoming messages,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random-id?

Copy link
Contributor Author

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")
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@troyronda troyronda Feb 26, 2020

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.

Copy link
Contributor Author

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"}`
Copy link
Contributor

@troyronda troyronda Feb 26, 2020

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.)

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

@llorllale
Copy link
Contributor

This new option requires a line in the docs

- 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>
@troyronda troyronda merged commit e1428b6 into hyperledger-archives:master Feb 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Aries Rest Client JS worker - Add websocket notifier
4 participants