arcam / CocoaUPnP

CocoaUPnP is a logical progression of upnpx; designed to be easy, modern and block-based.
MIT License
84 stars 40 forks source link

How to subscription event #41

Closed duydatpham closed 7 years ago

duydatpham commented 7 years ago

Hi friend, pls help me, I dont know how to subscription event . if u can, pls show me a example

Thanks

debugholic commented 7 years ago

That's easy.

Just add subscribeObserver to UPPEventSubscriptionManager as following.

[[UPPEventSubscriptionManager sharedInstance] subscribeObserver:device toService:device.avTransportService completion:nil];

You can received event through UPPEventSubscriptionDelegate protocol.

- (void)eventReceived:(NSDictionary *)event

I think maybe you want to subscribe 'LastChange' event and it is parsed UPPLastChangeParser. What you have to do is getting keys and values from event dictionary. If you want to subscribe other events, you should write those parsers. See OnoXML.

GOOD LUCK.

duydatpham commented 7 years ago

hi, many thanks for replying me :) But i check API, this function dont like you show me. (pls check image) screen shot 2017-03-14 at 09 53 39

If i'm trying to call like you said, i see that 'GCDWebServer stopped' on the console (pls check image) screen shot 2017-03-14 at 09 58 32 screen shot 2017-03-14 at 09 58 53 copy

squarefrog commented 7 years ago

You must subscribe an object conforming to the UPPEventSubscriptionDelegate, to an existing service not a new one.