ConnectSDK / Connect-SDK-iOS

iOS source project for Connect SDK
Apache License 2.0
174 stars 136 forks source link

DLNA Subscriptions are not stopping when the app disconnects from a device #118

Closed iadnan closed 9 years ago

iadnan commented 9 years ago

The DLNA subscriptions should stop once the device gets disconnected

eunikolsky commented 9 years ago

The cause is: the web server isn't stopped when the first device is disconnected and is still receiving events from it; also, a new instance cannot bind to the same port, and we don't receive events from the second device.

eunikolsky commented 9 years ago

Steps to reproduce:

  1. In the Sampler app, connect to a DLNA device.
  2. Change volume on the device. You should see logs indicating an event, like:
[DEBUG] Connection received 679 bytes on socket 13
[DEBUG] Connection on socket 13 preflighting request "NOTIFY /MediaRenderer/RenderingControl/Event" with 679 bytes body
[DEBUG] Connection on socket 13 processing request "NOTIFY /MediaRenderer/RenderingControl/Event" with 679 bytes body
[DEBUG] Connection sent 122 bytes on socket 13
[DEBUG] Did close connection on socket 13
  1. Disconnect from the device.
  2. Change volume on the same device.

Actual result: the events are still received and processed.

Expected result: the web server responsible for listening to DLNA events should be shut down, so the events aren't processed.

ps. stupid markdown parser doesn't want to continue the numbered list properly

eunikolsky commented 9 years ago

Currently, in DLNAService the only expected way to stop the web server is to unsubscribe from all the subscribed subscriptions, which doesn't happen on disconnect.

eunikolsky commented 9 years ago

The subscriptions are unsubscribed and the server is stopped on disconnect. The fix is available in https://github.com/eunikolsky/Connect-SDK-iOS-Core/tree/bugfix/118_dlna_disconnectfix. It's working properly on disconnect. The only thing to test is whether it works properly on suspending & resuming the app.

FIXME: if an app connects to 2+ DLNA devices at the same time, the events from the second device (most likely) won't work, because the DLNA server uses a static port, and the second instance won't be able to bind to it. We'll need to use dynamic ports later.

eunikolsky commented 9 years ago

Merged in Full and Lite.