{"action":"created","issue":{"url":"https://api.github.com/repos/ankraft/onem2mlib/issues/1","repository_url":"https://api.github.com/repos/ankraft/onem2mlib","labels_url":"https://api.github.com/repos/ankraft/onem2mlib/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ankraft/onem2mlib/issues/1/comments","events_url":"https://api.github.com/repos/ankraft/onem2mlib/issues/1/events","html_url":"https://github.com/ankraft/onem2mlib/issues/1","id":322550873,"number":1,"title":"Resource subscription.","user":{"login":"jairoseros","id":36413942,"avatar_url":"https://avatars0.githubusercontent.com/u/36413942?v=4","gravatar_id":"","url":"https://api.github.com/users/jairoseros","html_url":"https://github.com/jairoseros","followers_url":"https://api.github.com/users/jairoseros/followers","following_url":"https://api.github.com/users/jairoseros/following{/other_user}","gists_url":"https://api.github.com/users/jairoseros/gists{/gist_id}","starred_url":"https://api.github.com/users/jairoseros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jairoseros/subscriptions","organizations_url":"https://api.github.com/users/jairoseros/orgs","repos_url":"https://api.github.com/users/jairoseros/repos","events_url":"https://api.github.com/users/jairoseros/events{/privacy}","received_events_url":"https://api.github.com/users/jairoseros/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-12T23:37:26Z","updated_at":"2018-05-13T12:07:57Z","closed_at":"2018-05-13T03:12:13Z","author_association":"NONE","body":"Hello.\r\n\r\nWell this is not an issue. I would like to know how to make a subscription and it will be nice if you can explain to me how the notifications.py file works.\r\n\r\nBest regards."},"comment":{"url":"https://api.github.com/repos/ankraft/onem2mlib/issues/comments/388622102","html_url":"https://github.com/ankraft/onem2mlib/issues/1#issuecomment-388622102","issue_url":"https://api.github.com/repos/ankraft/onem2mlib/issues/1","id":388622102,"user":{"login":"ankraft","id":8394617,"avatar_url":"https://avatars3.githubusercontent.com/u/8394617?v=4","gravatar_id":"","url":"https://api.github.com/users/ankraft","html_url":"https://github.com/ankraft","followers_url":"https://api.github.com/users/ankraft/followers","following_url":"https://api.github.com/users/ankraft/following{/other_user}","gists_url":"https://api.github.com/users/ankraft/gists{/gist_id}","starred_url":"https://api.github.com/users/ankraft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankraft/subscriptions","organizations_url":"https://api.github.com/users/ankraft/orgs","repos_url":"https://api.github.com/users/ankraft/repos","events_url":"https://api.github.com/users/ankraft/events{/privacy}","received_events_url":"https://api.github.com/users/ankraft/received_events","type":"User","site_admin":false},"created_at":"2018-05-13T12:07:57Z","updated_at":"2018-05-13T12:07:57Z","author_association":"OWNER","body":"Thank you for your question.\r\nPlease have a look at the example in [subscription.py](https://github.com/ankraft/onem2mlib/blob/master/examples/subscription.py). This gives you a short introduction about how to add a subscription to a resource and how the handling is done.\r\n\r\nYou also don't really need to work with the notification.py file. It does the handling for received notifications by setting up a local http server to receive the notifications from a CSE, as well as executing the callback functions for the notifications.\r\n\r\nBasically, working with subscriptions works like this:\r\n- Import the Notification sub-module in your application and call the setup method ``setupNotifications()`` from this sub-module. This creates and starts the http server. You can do some configurations here, but the most important thing is that you can provide a default callback function that is called every time a notification is received and there is no other callback function specified.\r\n- You write one or more callback functions for handling the notifications. The only argument for a callback function is a resource object, ie. the resource of the notification.\r\n- Next, you get or create a resource you like to monitor and call the ``subscribe()``method of that resource. You also can add individual callback functions (or lambdas if you like) for each resource to do easier notification handling.\r\n- At the end of your application you should call the ``shutdownNotifications()`` function from the Notification sub-module (though this is done implicitly when your application terminates)."}}
{"actor":{"display_login":"ankraft"}}