8#define RESIPROCATE_SUBSYSTEM Subsystem::DUM
10DialogEventStateManager::DialogEventStateManager()
11 : mDialogEventHandler(nullptr)
17DialogEventStateManager::onTryingUas(Dialog& dialog,
const SipMessage&
invite)
19 DialogEventInfo*
eventInfo =
new DialogEventInfo();
20 eventInfo->mDialogEventId = Random::getVersion4UuidUrn();
22 eventInfo->mDirection = DialogEventInfo::Recipient;
23 eventInfo->mCreationTimeSeconds = Timer::getTimeSecs();
24 eventInfo->mInviteSession = InviteSessionHandle::NotValid();
26 eventInfo->mLocalIdentity = dialog.getLocalNameAddr();
27 eventInfo->mLocalTarget = dialog.getLocalContact().uri();
28 eventInfo->mRemoteIdentity = dialog.getRemoteNameAddr();
29 eventInfo->mRemoteTarget = std::unique_ptr<Uri>(
new Uri(dialog.getRemoteTarget().uri()));
30 eventInfo->mRouteSet = dialog.getRouteSet();
31 eventInfo->mState = DialogEventInfo::Trying;
43 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.find(*(
eventInfo->mReplacesId));
44 if (
it != mDialogIdToEventInfo.end())
48 if (
it->second->getState() != DialogEventInfo::Early ||
it->second->getDirection() != DialogEventInfo::Recipient)
50 it->second->mReplaced =
true;
60 mDialogIdToEventInfo[dialog.getId()] =
eventInfo;
63 mDialogEventHandler->onTrying(
evt);
68DialogEventStateManager::onTryingUac(DialogSet&
dialogSet,
const SipMessage&
invite)
71 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.find(
fakeId);
75 if (
it != mDialogIdToEventInfo.end())
79 if (
eventInfo->mState == DialogEventInfo::Trying)
89 eventInfo->mDialogEventId = Random::getVersion4UuidUrn();
91 eventInfo->mDirection = DialogEventInfo::Initiator;
92 eventInfo->mCreationTimeSeconds = Timer::getTimeSecs();
93 eventInfo->mInviteSession = InviteSessionHandle::NotValid();
103 eventInfo->mState = DialogEventInfo::Trying;
114 mDialogEventHandler->onTrying(
evt);
119DialogEventStateManager::onProceedingUac(
const DialogSet&
dialogSet,
const SipMessage&
response)
122 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.lower_bound(
fakeId);
123 if (
it != mDialogIdToEventInfo.end() &&
126 if (
it->first.getRemoteTag().empty())
130 eventInfo->mState = DialogEventInfo::Proceeding;
139 mDialogEventHandler->onProceeding(
evt);
154DialogEventStateManager::onEarly(
const Dialog& dialog, InviteSessionHandle
is)
156 DialogEventInfo*
eventInfo = findOrCreateDialogInfo(dialog);
160 eventInfo->mState = DialogEventInfo::Early;
161 eventInfo->mRouteSet = dialog.getRouteSet();
165 eventInfo->mLocalTarget = dialog.getLocalContact().uri();
166 eventInfo->mRemoteTarget = std::unique_ptr<Uri>(
new Uri(dialog.getRemoteTarget().uri()));
169 mDialogEventHandler->onEarly(
evt);
174DialogEventStateManager::onConfirmed(
const Dialog& dialog, InviteSessionHandle
is)
176 DialogEventInfo*
eventInfo = findOrCreateDialogInfo(dialog);
181 eventInfo->mRouteSet = dialog.getRouteSet();
183 eventInfo->mState = DialogEventInfo::Confirmed;
186 eventInfo->mLocalTarget = dialog.getLocalContact().uri();
187 eventInfo->mRemoteTarget = std::unique_ptr<Uri>(
new Uri(dialog.getRemoteTarget().uri()));
190 eventInfo->mLocalOfferAnswer = (
is->hasLocalOfferAnswer() ? std::unique_ptr<Contents>(
is->getLocalOfferAnswer().clone()) :
nullptr);
191 eventInfo->mRemoteOfferAnswer = (
is->hasRemoteOfferAnswer() ? std::unique_ptr<Contents>(
is->getRemoteOfferAnswer().clone()) :
nullptr);
197 MultipleEventDialogEvent::EventVector
events;
201 const DialogSetId&
dialogSetId = dialog.getId().getDialogSetId();
203 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.lower_bound(
fakeId);
204 while (
it != mDialogIdToEventInfo.end() &&
212 events.emplace_back(std::shared_ptr<TerminatedDialogEvent>(onDialogTerminatedImpl(
it->second, InviteSessionHandler::RemoteCancel)));
214 mDialogIdToEventInfo.erase(
it++);
226 mDialogEventHandler->onMultipleEvents(
multipleEvt);
236DialogEventStateManager::onTerminated(
const Dialog& dialog,
const SipMessage& msg, InviteSessionHandler::TerminatedReason reason)
238 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.find(dialog.getId());
239 if (
it != mDialogIdToEventInfo.end())
246 std::unique_ptr<TerminatedDialogEvent>
evt(onDialogTerminatedImpl(
it->second, reason, getResponseCode(msg), getFrontContact(msg)));
247 mDialogEventHandler->onTerminated(*
evt);
249 mDialogIdToEventInfo.erase(
it++);
253 onDialogSetTerminatedImpl(dialog.getId().getDialogSetId(), msg, reason);
258 onDialogSetTerminatedImpl(dialog.getId().getDialogSetId(), msg, reason);
263DialogEventStateManager::onTerminated(
const DialogSet&
dialogSet,
const SipMessage& msg, InviteSessionHandler::TerminatedReason reason)
265 onDialogSetTerminatedImpl(
dialogSet.getId(), msg, reason);
269DialogEventStateManager::onDialogSetTerminatedImpl(
const DialogSetId&
dialogSetId,
const SipMessage& msg, InviteSessionHandler::TerminatedReason reason)
284 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.lower_bound(
fakeId);
286 while (
it != mDialogIdToEventInfo.end() &&
290 std::unique_ptr<TerminatedDialogEvent>
evt(onDialogTerminatedImpl(
eventInfo, reason, getResponseCode(msg), getFrontContact(msg)));
291 mDialogEventHandler->onTerminated(*
evt);
293 mDialogIdToEventInfo.erase(
it++);
297TerminatedDialogEvent*
298DialogEventStateManager::onDialogTerminatedImpl(DialogEventInfo*
eventInfo,
299 InviteSessionHandler::TerminatedReason reason,
303 eventInfo->mState = DialogEventInfo::Terminated;
309 InviteSessionHandler::TerminatedReason
actualReason = reason;
318 eventInfo->mRemoteTarget = std::unique_ptr<Uri>(remoteTarget);
327DialogEventStateManager::getResponseCode(
const SipMessage& msg)
330 if (msg.isResponse())
332 respCode = msg.header(h_StatusLine).responseCode();
338DialogEventStateManager::getFrontContact(
const SipMessage& msg)
341 if (msg.isResponse())
354DialogEventStateManager::DialogEventInfos
355DialogEventStateManager::getDialogEventInfo()
const
358 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::const_iterator
it = mDialogIdToEventInfo.begin();
359 for (;
it != mDialogIdToEventInfo.end();
it++)
361 infos.push_back(*(
it->second));
370 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::const_iterator
it = mDialogIdToEventInfo.begin();
371 for (;
it != mDialogIdToEventInfo.end();
it++)
376 if (
it->second->getLocalIdentity().uri().getAOR(
false) ==
entityUri.getAOR(
false) ||
377 it->second->getRemoteIdentity().uri().getAOR(
false) ==
entityUri.getAOR(
false))
379 infos.push_back(*(
it->second));
385 if (
it->second->getRemoteIdentity().uri().getAOR(
false) ==
entityUri.getAOR(
false))
387 infos.push_back(*(
it->second));
395DialogEventStateManager::findOrCreateDialogInfo(
const Dialog& dialog)
407 std::map<DialogId, DialogEventInfo*, DialogIdComparator>::iterator
it = mDialogIdToEventInfo.find(dialog.
getId());
409 if (
it != mDialogIdToEventInfo.end())
418 it = mDialogIdToEventInfo.lower_bound(
fakeId);
420 if (
it != mDialogIdToEventInfo.end() &&
423 if (
it->first.getRemoteTag().empty())
427 mDialogIdToEventInfo.erase(
it);
433 DialogEventInfo*
newForkInfo =
new DialogEventInfo(*(
it->second));
434 newForkInfo->mDialogEventId = Random::getVersion4UuidUrn();
435 newForkInfo->mCreationTimeSeconds = Timer::getTimeSecs();
446 DebugLog(<<
"DialogSetId " <<
fakeId <<
" was not found! This indicates a bug; onTryingUax() should have been called first!");
#define resip_assert(x)
This file needs to work for both C and C++ code.
std::vector< DialogEventInfo > DialogEventInfos
const DialogSetId & getDialogSetId() const
dcm! – kill typedef std::list<DialogId> DialogIdSet;
const NameAddr & getRemoteNameAddr() const noexcept
const NameAddr & getRemoteTarget() const noexcept
const DialogId & getId() const noexcept
const NameAddrs & getRouteSet() const noexcept
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
dcm! – add UnusedChecking(_enum) below;