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

CoAP Observe Option #47

Open
SachinEdwin opened this issue Apr 13, 2016 · 1 comment
Open

CoAP Observe Option #47

SachinEdwin opened this issue Apr 13, 2016 · 1 comment

Comments

@SachinEdwin
Copy link

Hi,

I was able to register my CoAP sensor resource successfully and I get this notification every 30 secs, now I want to display this notification on a windows application, so for every change in state of the resource I want my display field to be updated. How do I handle this ? I see the notifications on wireshark, my windows application should get these notifications. How do I approach this ?

Edwin

@longshine
Copy link
Member

Hi~

This depends on how you register your observer.

With a Request object marked with Request.MarkObserve(), a Request.Respond event will be fired every time a notification is arrived. You can add a handler to that event to get the notification and update your window. For instance:

// create a new request
Request request;

// mark as observer
request.MarkObserve();

// add event handler
request.Respond += delegate(Object sender, ResponseEventArgs e)
{
    // this is a new notification
    Response response = e.Response;
    // TODO update window state here
    // you may need to switch to the UI thread first
};

// finally issue the request
request.Send();

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