1#if !defined(RESIP_DIALOGUSAGEMANAGER_HXX)
2#define RESIP_DIALOGUSAGEMANAGER_HXX
41class ClientAuthManager;
42class ServerAuthManager;
46class ClientRegistrationHandler;
47class ServerRegistrationHandler;
48class InviteSessionHandler;
49class ClientSubscriptionHandler;
50class ServerSubscriptionHandler;
51class ClientPublicationHandler;
52class ServerPublicationHandler;
53class ClientPagerMessageHandler;
54class ServerPagerMessageHandler;
55class OutOfDialogHandler;
57class DialogSetHandler;
58class RequestValidationHandler;
61class InviteSessionCreator;
63class AppDialogSetFactory;
64class DumShutdownHandler;
67class KeepAliveManager;
70class ConnectionTerminated;
72class ExternalMessageBase;
73class ExternalMessageHandler;
75class DialogEventStateManager;
76class DialogEventHandler;
90 const char*
name() const noexcept
override {
return "DialogUsageManager::Exception"; }
125 unsigned transportFlags = 0));
222 std::shared_ptr<SipMessage>
makeSubscription(
const NameAddr& target,
const std::shared_ptr<UserProfile>& userProfile,
const Data& eventType,
224 std::shared_ptr<SipMessage>
makeSubscription(
const NameAddr& target,
const std::shared_ptr<UserProfile>& userProfile,
const Data& eventType,
232 std::shared_ptr<SipMessage>
makeRefer(
const NameAddr& target,
const std::shared_ptr<UserProfile>& userProfile,
const H_ReferTo::Type& referTo,
AppDialogSet* =
nullptr);
236 const std::shared_ptr<UserProfile>& userProfile,
238 const Data& eventType,
243 const Data& eventType,
259 void send(std::shared_ptr<SipMessage> request);
260 void sendCommand(std::shared_ptr<SipMessage> request);
279 return strm <<
"DialogUsageManager::SendCommand" << std::endl;
317 template<
typename UnaryFunction>
319 const Data& eventType,
320 UnaryFunction& applyFn)
322 Data key = eventType + aor;
323 std::pair<ServerSubscriptions::iterator,ServerSubscriptions::iterator>
324 range = mServerSubscriptions.equal_range(key);
326 for (ServerSubscriptions::iterator i=range.first; i!=range.second; ++i)
417 virtual void post(std::unique_ptr<Message> msg)
419 mDum.incomingProcess(std::move(msg));
426 OutgoingTarget(DialogUsageManager& dum) : TargetCommand::
Target(dum)
430 virtual void post(std::unique_ptr<Message> msg)
432 mDum.outgoingProcess(std::move(msg));
436 DialogSet* makeUacDialogSet(BaseCreator* creator, AppDialogSet* appDs);
437 std::shared_ptr<SipMessage> makeNewSession(BaseCreator* creator, AppDialogSet* appDs);
440 void makeResponse(SipMessage& response,
441 const SipMessage& request,
445 void sendResponse(
const SipMessage& response);
447 void sendUsingOutboundIfAppropriate(UserProfile& userProfile, std::unique_ptr<SipMessage> msg);
450 unsigned long durationSeconds,
453 unsigned int altseq=0);
456 unsigned long duration,
459 unsigned int altseq=0,
462 Dialog& findOrCreateDialog(
const SipMessage* msg);
463 Dialog* findDialog(
const DialogId&
id);
464 DialogSet* findDialogSet(
const DialogSetId&
id);
467 BaseCreator* findCreator(
const DialogId&
id);
469 void processRequest(
const SipMessage& request);
470 void processResponse(
const SipMessage& response);
471 bool validateRequestURI(
const SipMessage& request);
472 bool validateRequiredOptions(
const SipMessage& request);
473 bool validateContent(
const SipMessage& request);
474 bool validateAccept(
const SipMessage& request);
475 bool validateTo(
const SipMessage& request);
476 bool validate100RelSupport(
const SipMessage& request);
478 bool mergeRequest(
const SipMessage& request);
480 void processPublish(
const SipMessage& publish);
482 void removeDialogSet(
const DialogSetId& );
484 bool checkEventPackage(
const SipMessage& request);
486 void incomingProcess(std::unique_ptr<Message> msg);
487 void outgoingProcess(std::unique_ptr<Message> msg);
488 void processExternalMessage(ExternalMessageBase* externalMessage);
495 void requestMergedRequestRemoval(
const MergedRequestKey&);
496 void removeMergedRequest(
const MergedRequestKey&);
498 typedef std::set<MergedRequestKey> MergedRequests;
499 MergedRequests mMergedRequests;
504 typedef std::unordered_map<Data, DialogSet*, KeyedDataHash> CancelMap;
505 CancelMap mCancelMap;
507 typedef HashMap<DialogSetId, DialogSet*> DialogSetMap;
508 DialogSetMap mDialogSetMap;
510 std::shared_ptr<MasterProfile> mMasterProfile;
511 std::shared_ptr<UserProfile> mMasterUserProfile;
512 std::unique_ptr<RedirectManager> mRedirectManager;
513 std::unique_ptr<ClientAuthManager> mClientAuthManager;
516 InviteSessionHandler* mInviteSessionHandler;
517 ClientRegistrationHandler* mClientRegistrationHandler;
518 ServerRegistrationHandler* mServerRegistrationHandler;
519 RedirectHandler* mRedirectHandler;
520 DialogSetHandler* mDialogSetHandler;
521 RequestValidationHandler* mRequestValidationHandler;
523 RegistrationPersistenceManager *mRegistrationPersistenceManager;
524 PublicationPersistenceManager *mPublicationPersistenceManager;
526 OutOfDialogHandler* getOutOfDialogHandler(
MethodTypes type);
528 std::map<Data, ClientSubscriptionHandler*> mClientSubscriptionHandlers;
529 std::map<Data, ServerSubscriptionHandler*> mServerSubscriptionHandlers;
530 std::map<Data, ClientPublicationHandler*> mClientPublicationHandlers;
531 std::map<Data, ServerPublicationHandler*> mServerPublicationHandlers;
532 std::map<MethodTypes, OutOfDialogHandler*> mOutOfDialogHandlers;
533 std::unique_ptr<KeepAliveManager> mKeepAliveManager;
534 bool mIsDefaultServerReferHandler;
536 ClientPagerMessageHandler* mClientPagerMessageHandler;
537 ServerPagerMessageHandler* mServerPagerMessageHandler;
538 std::vector<ExternalMessageHandler*> mExternalMessageHandlers;
542 DialogEventStateManager* mDialogEventStateManager;
544 std::unique_ptr<AppDialogSetFactory> mAppDialogSetFactory;
547 DumShutdownHandler* mDumShutdownHandler;
552 RemovingTransactionUser,
556 ShutdownState mShutdownState;
559 typedef std::map<Data, ServerPublication*> ServerPublications;
560 ServerPublications mServerPublications;
563 typedef std::multimap<Data, ServerSubscription*> ServerSubscriptions;
564 ServerSubscriptions mServerSubscriptions;
566 IncomingTarget* mIncomingTarget;
567 OutgoingTarget* mOutgoingTarget;
571 EventDispatcher<ConnectionTerminated> mConnectionTerminatedEventDispatcher;
websocketpp::client< websocketpp::config::asio_client > client
The abstract base-class for all exceptions thrown by resip code.
Represents the "callid" element in the SIP grammar.
dcm! – shutdown/deletion API – end?
dcm! – update contact in dialog if required
Base class for all SIP body types.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
Implements the FSM for dialog state as spec'd in RFC 4235.
const char * name() const noexcept override
Exception(const Data &msg, const Data &file, const int line)
EncodeStream & encodeBrief(EncodeStream &strm) const override
output a brief description to stream
SendCommand(std::shared_ptr< SipMessage > request, DialogUsageManager &dum)
void executeCommand() override
std::shared_ptr< SipMessage > mRequest
DialogUsageManager & mDum
FeatureChainMap mIncomingFeatureChainMap
void addTransport(TransportType protocol, int port=0, IpVersion version=V4, const Data &ipInterface=Data::Empty, const Data &sipDomainname=Data::Empty, const Data &privateKeyPassPhrase=Data::Empty, SecurityTypes::SSLType sslType=SecurityTypes::DynamicTLS, unsigned transportFlags=0)
void setClientRegistrationHandler(ClientRegistrationHandler *)
If there is no such handler, calling makeRegistration will throw.
void addServerPublicationHandler(const Data &eventType, ServerPublicationHandler *)
void addOutOfDialogHandler(MethodTypes, OutOfDialogHandler *)
DialogEventStateManager * createDialogEventStateManager(DialogEventHandler *handler)
void send(std::shared_ptr< SipMessage > request)
void addExternalMessageHandler(ExternalMessageHandler *handler)
Add/Remove External Message Handler do following op when processing thread in not running.
void shutdown(DumShutdownHandler *)
virtual const Data & name() const
Return the name of this TransactionUser.
void applyToAllServerSubscriptions(ServerSubscriptionFunctor *)
void setInviteSessionHandler(InviteSessionHandler *)
If there is no such handler, calling makeInviteSession will throw and receiving an INVITE as a UAS wi...
void setClientAuthManager(std::unique_ptr< ClientAuthManager > client) noexcept
If there is no ClientAuthManager, when the client receives a 401/407, pass it up through the normal B...
std::shared_ptr< DumFeature > mOutgoingMessageInterceptor
void setServerPagerMessageHandler(ServerPagerMessageHandler *) noexcept
void addClientPublicationHandler(const Data &eventType, ClientPublicationHandler *)
If there is no such handler, calling makePublication will throw.
void setServerRegistrationHandler(ServerRegistrationHandler *)
If no such handler, UAS will respond to REGISTER with 405 Method Not Allowed.
void setRedirectManager(std::unique_ptr< RedirectManager > redirect) noexcept
std::shared_ptr< UserProfile > & getMasterUserProfile()
void removeExternalMessageHandler(ExternalMessageHandler *handler)
RegistrationPersistenceManager * getRegistrationPersistenceManager()
std::shared_ptr< SipMessage > makePublication(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, const Contents &body, const Data &eventType, uint32_t expiresSeconds, AppDialogSet *=nullptr)
bool process(Mutex *mutex=NULL)
void end(DialogSetId invSessionId)
std::shared_ptr< SipMessage > makeRefer(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, const H_ReferTo::Type &referTo, AppDialogSet *=nullptr)
void setServerAuthManager(std::shared_ptr< ServerAuthManager > server)
If there is no ServerAuthManager, the server does not authenticate requests.
void setDialogSetHandler(DialogSetHandler *handler) noexcept
void setRegistrationPersistenceManager(RegistrationPersistenceManager *)
Sets a manager to handle storage of registration or publication state.
std::shared_ptr< SipMessage > makeInviteSession(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, const Contents *initialOffer, AppDialogSet *ads=nullptr)
RedirectHandler * getRedirectHandler() const noexcept
void clearExternalMessageHandler()
ClientPublicationHandler * getClientPublicationHandler(const Data &eventType)
DumFeatureChain::FeatureList mOutgoingFeatureList
InviteSessionHandle findInviteSession(const DialogId &id)
std::shared_ptr< SipMessage > makeOutOfDialogRequest(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, MethodTypes meth, AppDialogSet *=nullptr)
ClientSubscriptionHandler * getClientSubscriptionHandler(const Data &eventType)
void registerForConnectionTermination(Postable *)
Note: Implementations of Postable must delete the message passed via post.
ServerPublicationHandler * getServerPublicationHandler(const Data &eventType)
virtual ~DialogUsageManager()
FeatureChainMap mOutgoingFeatureChainMap
void endAllServerPublications()
AppDialogSetHandle findAppDialogSet(const DialogSetId &id)
TargetCommand::Target & dumOutgoingTarget()
void setMasterProfile(const std::shared_ptr< MasterProfile > &masterProfile)
void addIncomingFeature(std::shared_ptr< DumFeature > feat)
void sendCommand(std::shared_ptr< SipMessage > request)
TargetCommand::Target & dumIncomingTarget()
void endAllServerSubscriptions(TerminateReason reason=Deactivated)
void addOutgoingFeature(std::shared_ptr< DumFeature > feat)
void setClientPagerMessageHandler(ClientPagerMessageHandler *) noexcept
ClientPagerMessageHandle makePagerMessage(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, AppDialogSet *=nullptr)
void applyToAllClientSubscriptions(ClientSubscriptionFunctor *)
ServerSubscriptionHandler * getServerSubscriptionHandler(const Data &eventType)
friend class KeepAliveAssociation
void setAppDialogSetFactory(std::unique_ptr< AppDialogSetFactory >) noexcept
void setRequestValidationHandler(RequestValidationHandler *)
void setOutgoingMessageInterceptor(std::shared_ptr< DumFeature > feat) noexcept
PublicationPersistenceManager * getPublicationPersistenceManager()
void addServerSubscriptionHandler(const Data &eventType, ServerSubscriptionHandler *)
bool messageAvailable(void)
AppDialogHandle findAppDialog(const DialogId &id)
DumFeatureChain::FeatureList mIncomingFeatureList
void internalProcess(std::unique_ptr< Message > msg)
void setKeepAliveManager(std::unique_ptr< KeepAliveManager > keepAlive) noexcept
std::map< Data, DumFeatureChain * > FeatureChainMap
std::shared_ptr< SipMessage > makeInviteSessionFromRefer(const SipMessage &refer, ServerSubscriptionHandle, const Contents *initialOffer, AppDialogSet *=nullptr)
virtual void onAllHandlesDestroyed()
friend class TargetCommand::Target
void setPublicationPersistenceManager(PublicationPersistenceManager *)
std::shared_ptr< MasterProfile > & getMasterProfile()
void unRegisterForConnectionTermination(Postable *)
Message * getNext(int ms)
void setAdvertisedCapabilities(SipMessage &msg, const std::shared_ptr< UserProfile > &userProfile)
void setRedirectHandler(RedirectHandler *handler) noexcept
std::shared_ptr< SipMessage > makeRegistration(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, AppDialogSet *=nullptr)
UnaryFunction applyToServerSubscriptions(const Data &aor, const Data &eventType, UnaryFunction &applyFn)
void forceShutdown(DumShutdownHandler *)
void addClientSubscriptionHandler(const Data &eventType, ClientSubscriptionHandler *)
If there is no such handler, calling makeSubscription will throw.
std::shared_ptr< SipMessage > makeSubscription(const NameAddr &target, const std::shared_ptr< UserProfile > &userProfile, const Data &eventType, AppDialogSet *=nullptr)
dcm! – kill typedef std::list<DialogId> DialogIdSet;
std::vector< std::shared_ptr< DumFeature > > FeatureList
Base class for class ClientInviteSession and class ServerInviteSession.
The base-class used for message-passing.
Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.
Abstract interface of a datastore of all publication documents processed by DUM.
Abstract interface of a datastore of all registered endpoints processed by DUM.
Handler used to know when an incoming request failed validation.
dcm! – no Subscription State expires parameter generation yet.
ServerSubscriptionHandle getHandle() const
Represents a SIP message.
This is the primary point of interaction between the app-layer and the stack.
DialogUsageManager & mDum
The base-class for an RFC 3261 Transaction User.
TimeLimitFifo< Message > mFifo
This TransactionUser's fifo.
#define RESIP_DEPRECATED(x)
SSLType
Note: Before adding to the SSLType enum, please see the comments about mTlsCtx in resip/stack/ssl/Sec...
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Handle< BaseUsage > BaseUsageHandle
Handle< AppDialog > AppDialogHandle
TransportType
An enumeration of transport protocols.
std::recursive_mutex RecursiveMutex
IpVersion
An enumeration of IP versions.