Make sure replies to subscribe and unsubscribe methods arrive before any
other action is taken.
This commit is contained in:
parent
f0689df5f6
commit
4aa1c54a8a
1 changed files with 16 additions and 3 deletions
19
htsp.c
19
htsp.c
|
@ -414,11 +414,18 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
|
|||
if((ch = channel_find_by_identifier(chid)) == NULL)
|
||||
return htsp_error("Requested channel does not exist");
|
||||
|
||||
|
||||
/*
|
||||
* We send the reply here or the user will get the 'subscriptionStart'
|
||||
* async message before the reply to 'subscribe'.
|
||||
*/
|
||||
htsp_reply(htsp, in, htsmsg_create());
|
||||
|
||||
s = subscription_create_from_channel(ch, 500, "htsp",
|
||||
htsp_subscription_callback, htsp, sid);
|
||||
|
||||
LIST_INSERT_HEAD(&htsp->htsp_subscriptions, s, ths_subscriber_link);
|
||||
return htsmsg_create();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -438,12 +445,18 @@ htsp_method_unsubscribe(htsp_connection_t *htsp, htsmsg_t *in)
|
|||
if(s->ths_u32 == sid)
|
||||
break;
|
||||
|
||||
/*
|
||||
* We send the reply here or the user will get the 'subscriptionStart'
|
||||
* async message before the reply to 'subscribe'.
|
||||
*/
|
||||
htsp_reply(htsp, in, htsmsg_create());
|
||||
|
||||
if(s == NULL)
|
||||
return htsmsg_create(); /* Just say ok */
|
||||
return NULL; /* Subscription did not exist, but we don't really care */
|
||||
|
||||
LIST_REMOVE(s, ths_subscriber_link);
|
||||
subscription_unsubscribe(s);
|
||||
return htsmsg_create();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue