1
#include "resip/stack/Helper.hxx"
3
#include "ResourceMgr.h"
15
mStack->buildFdSet(fdset);
16
// int err = fdset.selectMilliSeconds(0);
17
int err = fdset.selectMilliSeconds(100);
20
mStack->process(fdset);
22
SipMessage* msg = (mStack->receive());
27
if (msg->header(h_RequestLine).getMethod() == SUBSCRIBE )
29
processSubscribe(msg);
31
else if (msg->header(h_RequestLine).getMethod() == REGISTER )
35
else if (msg->header(h_RequestLine).getMethod() == OPTIONS )
37
auto_ptr<SipMessage> resp(
38
Helper::makeResponse(*msg,500,"You Shot Me!"));
42
else if (msg->header(h_RequestLine).getMethod() == PUBLISH)
48
auto_ptr<SipMessage> resp(Helper::makeResponse(*msg,501,""));
55
Nope - dialog key is currently overscoped to requests - bad.
56
assert(msg->isResponse());
57
if (msg->header(h_CSeq).method()==NOTIFY)
58
mDialogMgr.dispatchNotifyResponse(msg);
63
mDialogMgr.processExpirations();
69
TuPresSvr::processSubscribe(SipMessage* msg)
71
// See if this subscribe matches a dialog we have in progress
72
if (mDialogMgr.dialogExists(msg))
74
mDialogMgr.dispatchSubscribe(msg);
78
processNewSubscribe(msg);
82
void TuPresSvr::processNewSubscribe(SipMessage* msg)
84
static Token presence("presence");
85
if ( !msg->exists(h_Event)
86
|| msg->header(h_Event).value()!=presence.value()
89
auto_ptr<SipMessage> resp(Helper::makeResponse(*msg,489,""));
90
resp->header(h_AllowEvents).push_back(presence);
95
if (ResourceMgr::instance()
96
.exists(msg->header(h_RequestLine).uri().getAorNoPort()))
98
mDialogMgr.dispatchNewSubscribe(msg);
102
auto_ptr<SipMessage> resp(Helper::makeResponse(*msg,404,""));
108
void TuPresSvr::processPublish(SipMessage* msg)
110
//ignore any PUBLISH related headers and any contacts
111
//provided in a REGISTER
112
//This is a rather vile hack for SIMPLEt 1
114
if ( msg->header(h_RequestLine).getMethod() == REGISTER )
116
aor = msg->header(h_To).uri().getAorNoPort();
120
aor = msg->header(h_RequestLine).uri().getAorNoPort();
122
if (ResourceMgr::instance().exists(aor))
124
Contents * contents = msg->getContents();
127
int retcode = (ResourceMgr::instance().setPresenceDocument(aor,contents)
129
auto_ptr<SipMessage> resp(Helper::makeResponse(*msg,retcode,""));
134
auto_ptr<SipMessage> resp(Helper::makeResponse(*msg,400,"This hacked-up service requires a body"));
140
auto_ptr<SipMessage> resp(Helper::makeResponse(*msg,404,""));