Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage Documentation #19

Open
ammopt opened this issue Oct 8, 2021 · 1 comment
Open

Usage Documentation #19

ammopt opened this issue Oct 8, 2021 · 1 comment

Comments

@ammopt
Copy link

ammopt commented Oct 8, 2021

NGSI-Proxy Usage Documentation

  • Create eventsource:

    curl -X POST {{ngsiproxyurl}}/eventsource
    

    Sample create eventsource response:

    { 
     "connection_id":"353529a0-281a-11ec-b25b-6d62e91d5158",
     "url":"{{ngsiproxyurl}}/eventsource/353529a0-281a-11ec-b25b-6d62e91d5158"
    }
    
  • Create callback:

    Use the previously generated connection_id to create the
    callback:

    curl -X POST '{{ngsiproxyurl}}/callbacks' \
    --data-raw '{
                "connection_id": "353529a0-281a-11ec-b25b-6d62e91d5158"
    }'
    

    Sample create callback response:

    {
     "callback_id":"40b18800-281a-11ec-b25b-6d62e91d5158",
     "url":"{{ngsiproxyurl}}/callbacks/40b18800-281a-11ec-b25b-6d62e91d5158"
    }
    
  • Consume callback:

    The callback to be notified by the context-broker through a
    subscription. Use the previously generated callback_id to create
    the callback:

    curl -X POST '{{ngsiproxyurl}}/callbacks/40b18800-281a-11ec-b25b-6d62e91d5158' \
    --data-raw '{
     	    "keyofpayloadcontent": "valueofpayloadcontent"
    }'
    
  • Sample EventSource:

    Use the url returned in "Create eventsource"

    const sse = new EventSource('{{ngsiproxyurl}}/eventsource/353529a0-281a-11ec-b25b-6d62e91d5158');
    sse.addEventListener("notification", function(e) {
      console.log(JSON.parse(e.data));
    }) 
    

    This EventSource will fire everytime the callback is consumed.

@aarranz
Copy link
Member

aarranz commented Oct 25, 2021

Thank you @ammopt for your collaboration!

Do you mind to create a PR to create this as a markdown file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants