begin last conference event notify sent/received management

This commit is contained in:
Benjamin Reis 2017-10-12 12:10:35 +02:00
parent a780121af0
commit dc80931672
4 changed files with 28 additions and 12 deletions

View file

@ -24,6 +24,7 @@
#include "local-conference-event-handler.h"
#include "object/object-p.h"
#include "xml/conference-info.h"
LINPHONE_BEGIN_NAMESPACE
@ -32,6 +33,7 @@ public:
void notifyFullState (const std::string &notify, LinphoneEvent *lev);
void notifyAllExcept (const std::string &notify, const Address &addr);
void notifyAll (const std::string &notify);
std::string createNotify (Xsd::ConferenceInfo::ConferenceType confInfo);
std::string createNotifyFullState ();
std::string createNotifyParticipantAdded (const Address &addr);
std::string createNotifyParticipantRemoved (const Address &addr);
@ -40,10 +42,13 @@ public:
std::string createNotifyParticipantDeviceAdded (const Address &addr, const Address &gruu);
std::string createNotifyParticipantDeviceRemoved (const Address &addr, const Address &gruu);
inline unsigned int getLastNotify () const { return lastNotify; };
private:
LinphoneCore *core = nullptr;
LocalConference *conf = nullptr;
unsigned int lastNotify = 0;
void sendNotify (const std::string &notify, const Address &addr);
L_DECLARE_PUBLIC(LocalConferenceEventHandler);

View file

@ -21,11 +21,8 @@
#include "conference/participant-p.h"
#include "local-conference-event-handler-p.h"
#include "object/object-p.h"
#include "private.h"
#include "xml/conference-info.h"
// =============================================================================
using namespace std;
@ -44,14 +41,6 @@ static void doNotify (const string &notify, LinphoneEvent *lev) {
linphone_event_unref(lev);
}
static string createNotify (ConferenceType confInfo) {
stringstream notify;
Xsd::XmlSchema::NamespaceInfomap map;
map[""].name = "urn:ietf:params:xml:ns:conference-info";
serializeConferenceInfo(notify, confInfo, map);
return notify.str();
}
// -----------------------------------------------------------------------------
void LocalConferenceEventHandlerPrivate::notifyFullState (const string &notify, LinphoneEvent *lev) {
@ -76,6 +65,18 @@ void LocalConferenceEventHandlerPrivate::notifyAll (const string &notify) {
}
}
string LocalConferenceEventHandlerPrivate::createNotify (ConferenceType confInfo) {
if (confInfo.getVersion().present()) {
lastNotify = confInfo.getVersion().get() + 1;
confInfo.setVersion(lastNotify);
}
stringstream notify;
Xsd::XmlSchema::NamespaceInfomap map;
map[""].name = "urn:ietf:params:xml:ns:conference-info";
serializeConferenceInfo(notify, confInfo, map);
return notify.str();
}
string LocalConferenceEventHandlerPrivate::createNotifyFullState () {
string entity = conf->getConferenceAddress()->asStringUriOnly();
string subject = conf->getSubject();
@ -248,6 +249,7 @@ LocalConferenceEventHandler::LocalConferenceEventHandler (LinphoneCore *core, Lo
xercesc::XMLPlatformUtils::Initialize();
d->conf = localConf;
d->core = core;
//init d->lastNotify = last notify
}
LocalConferenceEventHandler::~LocalConferenceEventHandler () {

View file

@ -26,11 +26,15 @@
LINPHONE_BEGIN_NAMESPACE
class RemoteConferenceEventHandlerPrivate : public ObjectPrivate {
public:
inline unsigned int getLastNotify () const { return lastNotify; };
private:
LinphoneCore *core = nullptr;
ConferenceListener *listener = nullptr;
Address confAddress;
LinphoneEvent *lev = nullptr;
unsigned int lastNotify = 0;
L_DECLARE_PUBLIC(RemoteConferenceEventHandler);
};

View file

@ -38,6 +38,7 @@ RemoteConferenceEventHandler::RemoteConferenceEventHandler (LinphoneCore *core,
xercesc::XMLPlatformUtils::Initialize();
d->core = core;
d->listener = listener;
// TODO : d->lastNotify = lastNotify
}
RemoteConferenceEventHandler::~RemoteConferenceEventHandler () {
@ -48,6 +49,7 @@ RemoteConferenceEventHandler::~RemoteConferenceEventHandler () {
void RemoteConferenceEventHandler::subscribe (const Address &addr) {
L_D();
// TODO : add last notify
d->confAddress = addr;
LinphoneAddress *lAddr = linphone_address_new(d->confAddress.asString().c_str());
d->lev = linphone_core_create_subscribe(d->core, lAddr, "conference", 600);
@ -76,6 +78,9 @@ void RemoteConferenceEventHandler::notifyReceived (string xmlBody) {
if (confInfo->getConferenceDescription().present() && confInfo->getConferenceDescription().get().getSubject().present())
d->listener->onSubjectChanged(confInfo->getConferenceDescription().get().getSubject().get());
if (confInfo->getVersion().present())
d->lastNotify = confInfo->getVersion().get();
if (!confInfo->getUsers().present())
return;