[reSIProcate] Adding a public getSubscriptionState() method to BaseSubscription?
Hi,
I'm implementing a ServerSubscriptionHandler for the dum in my program and I'd
like to always respond to UAC subscribe requests with a 202 OK (pending) and
prompt the user to allow or disallow the subscription. So far my
onNewSubscription method looks like this:
MyServerSubscriptionHandler::onNewSubscription(ServerSubscriptionHandle ssh,
const SipMessage& sub)
{
ssh.get()->setSubscriptionState( Pending );
SipMessage ok = ssh.get()->accept(202);
SipMessage notify = ssh.get()->neutralNotify();
notify.header(h_SubscriptionState).param(p_expires) =
sub.header(h_Expires).value();
ssh.get()->send( ok );
ssh.get()->send( notify );
// TODO prompt the user
}
As the user could take a long time to respond, the client subscriber could
send a refresh request before the subscription times out. In that case I'd
like to check if the subscription-state is still "Pending" or if the user
allowed the subscription and the state is "Active". In the first case I'd
send another 202/neutralNotify and in the second case I'd send a 200 and a
notify with a real Pidf. I'd like my onRefresh method to look something like
this:
MyServerSubscriptionHandler::onRefresh(ServerSubscriptionHandle ssh, const
SipMessage& sub)
{
SipMessage ok, notify;
if ( ssh.get()->getSubscriptionState() == Pending )
{
ok = ssh.get()->accept(202);
notify = ssh.get()->neutralNotify();
}
else if ( ssh.get()->getSubscriptionState() == Active )
{
ok = ssh.get()->accept();
notify = ssh.get()->update( getPidf() );
}
notify.header(h_SubscriptionState).param(p_expires) =
sub.header(h_Expires).value();
ssh.get()->send( ok );
ssh.get()->send( notify );
}
This doesn't work because getSubscriptionState() is protected in
BaseSubscription even though setSubscriptionState() is public in
ServerSubscription. Does anyone else think it would it make sense to add a
const public getSubscriptionState() method to BaseSubscription or
ServerSubscription or is there a better way to do what I'm trying to do?
Regards,
~Scott