-
Notifications
You must be signed in to change notification settings - Fork 299
DUM Associating Application Data with DialogSets and Dialogs
An application can associate user data with Dialog/DialogSet by overriding the AppDialog, AppDialogSet and AppDialogSetFactory classes.
1. The application should create classes inherited from AppDialog, AppDialogSet and AppDialogSetFactory. These classes can then contain any application specific data.
2. Register your AppDialogSetFactory with the Dialog Usage Manager by calling: dum->setAppDialogSetFactory(...)
3. For the UAC side - when a new dialogset/dialog is to be created. Create one of the AppDialogSet inherited objects and pass it into the DUM makeXXXX functions.
4. For the UAS side - override createAppDialogSet function from AppDialogSetFactory so that the object (inherited from AppDialogSet) is created instead of the base AppDialogSet object.
5. The handlers can get at data in the AppDialog or AppDialogSet by calling getAppDialog() or getAppDialogSet on the usage handle and casting the result to the inherited class.
For example - In this case the user data is just an int...
class TestAppDialog : public AppDialog { public: TestAppDialog(HandleManager& ham, int portID) : AppDialog(ham), m_portID(portID) { InfoLog( << "TestAppDialogSet::TestAppDialog: " << m_portID); } virtual ~TestAppDialog() { InfoLog( << "TestAppDialog::~TestAppDialog: " << m_portID); } int m_portID; };
class TestAppDialogSet : public AppDialogSet { public: TestAppDialogSet(DialogUsageManager& dum, int portID) : AppDialogSet(dum), m_portID(portID) { InfoLog( << "TestAppDialogSet::TestAppDialogSet: " << m_portID); } virtual ~TestAppDialogSet() { InfoLog( << "TestAppDialogSet::~TestAppDialogSet: " << m_portID); } virtual AppDialog* createAppDialog(const SipMessage& msg) { InfoLog( << "TestAppDialogSet::createAppDialog: " << m_portID << ", " << msg.brief()); return new TestAppDialog(mDum, m_portID); } int m_portID; };
class TestAppDialogSetFactory : public AppDialogSetFactory { public: virtual AppDialogSet* createAppDialogSet(DialogUsageManager& dum, const SipMessage& msg) { InfoLog( << "TestAppDialogSetFactory::createAppDialogSet: " << msg.brief()); return new TestAppDialogSet(dum, application.getPortID()); // For a UAS the testAppDialogSet will be created by DUM using this function. If you want to set // Application Data, another approach is to wait for onNewSession(ServerInviteSessionHandle ...) // to be called, then use the ServerInviteSessionHandle to get at the AppDialogSet or AppDialog, // then cast to your derived class and set the desired application data. } };
TestAppDialogSetFactory testAppDialogSetFactory; dum->setAppDialogSetFactory(testAppDialogSetFactory);
Client side sample code:
dumUac->send(dumUac->makeInviteSession(uasAor, uac.sdp, new TestAppDialogSet(*dumUac, 1110000)));
Handler Sample code for accessing user data:
.... virtual void onNewSession(ServerInviteSessionHandle sis, InviteSession::OfferAnswerType oat, const SipMessage& msg) { int portID = ((TestAppDialog*)sis->getAppDialog().get())->m_portID; InfoLog( << "[" << portID << "] TestUAS::onNewSession(ServerInviteSessionHandle): " << name << " " << endl << msg); mSis = sis; sis->provisional(180); }
- Navigation
- Developers
- Packages
- Community