/[resiprocate]/main/resip/dum/Dialog.cxx
ViewVC logotype

Annotation of /main/resip/dum/Dialog.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2539 - (hide annotations) (download)
Sun Apr 4 05:22:08 2004 UTC (15 years, 8 months ago) by jason
Original Path: main/sip/resiprocate/dum/Dialog.cxx
File size: 5001 byte(s)
*** empty log message ***

1 ken 2520 #include "resiprocate/sam/nnDialog.hxx"
2    
3     using namespace resip;
4     using namespace std;
5    
6     DialogId Dialog;:getId() const
7     {
8     return mId;
9     }
10    
11     BaseUsage&
12     Dialog::findInvSession()
13     {
14 ken 2521 std::list<BaseUsage*>::iterator it = mUsages.begin();
15 ken 2520 BaseUsage *usage;
16     while (it != mUsages.end())
17     {
18     usage = it.next();
19 ken 2521 if ((dynamic_cast<ClientInviteSession*>(usage) != null) ||
20     (dynamic_cast<ServerInviteSession*>(usage) != null))
21 ken 2520 {
22     return *usage;
23     }
24     }
25 ken 2521 return BaseUsage::empty();
26 ken 2520 }
27    
28     UsageSet
29     Dialog::findSubscriptions()
30     {
31 ken 2521 std::list<BaseUsage*>::iterator it = mUsages.begin();
32 ken 2520 BaseUsage *usage;
33     UsageSet usageSet;
34     while (it != mUsages.end())
35     {
36     usage = it.next();
37 ken 2521 if ((dynamic_cast<ClientSubscription*>(usage) != null) ||
38     (dynamic_cast<ServerSubscription*>(usage) != null))
39 ken 2520 {
40     usageSet.push_back(*usage);
41     }
42     }
43     return usageSet:
44     }
45    
46     BaseUsage&
47     Dialog::findRegistration()
48     {
49 ken 2521 std::list<BaseUsage*>::iterator it = mUsages.begin();
50 ken 2520 BaseUsage *usage;
51     while (it != mUsages.end())
52     {
53     usage = it.next();
54 ken 2521 if ((dynamic_cast<CientRegistration*>(usage) != null) ||
55     (dynamic_cast<ServerRegistration*>(usage) != null))
56 ken 2520 {
57     return *usage;
58     }
59     }
60 ken 2521 return BaseUsage::empty();
61 ken 2520 }
62    
63    
64     BaseUsage&
65     Dialog::findPublication()
66     {
67 ken 2521 std::list<BaseUsage*>::iterator it = mUsages.begin();
68 ken 2520 BaseUsage *usage;
69     while (it != mUsages.end())
70     {
71     usage = it.next();
72 ken 2521 if ((dynamic_cast<CientPublication*>(usage) != null) ||
73     (dynamic_cast<ServerPublication*>(usage) != null))
74 ken 2520 {
75 ken 2521 return *usage;
76 ken 2520 }
77     }
78 ken 2521 return BaseUsage::empty();
79 ken 2520 }
80    
81     UsageSet
82     Dialog::findOutOfDialogs()
83     {
84 ken 2521 std::list<BaseUsage*>::iterator it = mUsages.begin();
85 ken 2520 BaseUsage *usage;
86     UsageSet usageSet;
87     while (it != mUsages.end())
88     {
89     usage = it.next();
90 ken 2521 if ((dynamic_cast<ClientOutOfDialogReq*>(usage) != null) ||
91     (dynamic_cast<ServerOutOfDialogReq*>(usage) != null))
92 ken 2520 {
93     usageSet.push_back(*usage);
94     }
95     }
96     return usageSet:
97     }
98 jason 2535
99     void
100 jason 2539 Dialog::process(const SipMessage& msg)
101     {
102     switch (request.header(h_RequestLine).getMethod())
103     {
104     // a NOTIFY is the only request that can
105     // create a full dialog (when the 2xx from the
106     // SUBSCRIBE arrives *after* the NOTIFY
107     case NOTIFY :
108     processNotify(msg);
109     break;
110    
111     case REFER:
112     // !jf! wierdo
113     // affects an InvSession and a ServerSubscription
114     break;
115    
116     case SUBSCRIBE:
117     processSubscribe(msg);
118     break;
119    
120     case CANCEL:
121     // should only occur when canceling a re-INVITE
122     case INVITE:
123     // should only occur for a re-INVITE
124     case ACK:
125     case PRACK:
126     case BYE:
127     case UPDATE:
128     case INFO:
129     processInviteRelated(msg);
130     break;
131    
132     case REGISTER:
133     {
134     assert(0); // already handled
135     break;
136     }
137    
138     case PUBLISH:
139     assert(0);
140     break;
141    
142     case MESSAGE:
143     case OPTIONS:
144     assert(0);
145     break;
146    
147     default:
148     assert(0);
149     break;
150     }
151     }
152    
153     void
154 jason 2535 Dialog::processNotify(const SipMessage& notify)
155     {
156     if (notify.isRequest())
157     {
158     if (findSubscriptions().empty())
159     {
160     SubscriptionCreator* creator = dynamic_cast<SubscriptionCreator*>(DialogSetId(notify).getCreator());
161     if (creator)
162     {
163     creator->makeNewSubscription(notify);
164     }
165     }
166     else
167     {
168     for (std::list<BaseUsage*>::iterator i=mUsages.begin(); i!=mUsages.end(); i++)
169     {
170     ClientSubscription* sub = dynamic_cast<ClientSubscription*>(*i);
171     if (sub && sub->matches(notify))
172     {
173     sub->process(notify);
174     break;
175     }
176     }
177     }
178     }
179     }
180 jason 2539
181     void
182     Dialog::processSubscribe(const SipMessage& subscribe)
183     {
184     for (std::list<BaseUsage*>::iterator i=mUsages.begin(); i!=mUsages.end(); i++)
185     {
186     ServerSubscription* sub = dynamic_cast<ServerSubscription*>(*i);
187     if (sub && sub->matches(subscribe))
188     {
189     sub->process(subscribe); // a resubscribe or unsubscribe
190     return;
191     }
192     }
193    
194     // a subscribe on an existing dialog with a different BaseUsage
195     ServerSubscription* sub = new ServerSubscription(mDum, subscribe);
196     }
197    
198     void
199     Dialog::processInviteRelated(const SipMessage& msg)
200     {
201     for (std::list<BaseUsage*>::iterator i=mUsages.begin(); i!=mUsages.end(); i++)
202     {
203     ServerInvSession* server = dynamic_cast<ServerInvSession*>(*i);
204     ClientInvSession* client = dynamic_cast<ClientInvSession*>(*i);
205     if (server)
206     {
207     server->process(msg);
208     break;
209     }
210     else if (client)
211     {
212     client->process(msg);
213     break;
214     }
215     }
216     }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27