|
|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
|
|
|
|
|
#include "RoomInfo.h"
|
|
|
|
|
#include "WebConference.h"
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
|
|
@ -11,10 +13,13 @@ bool ConferenceRoomParticipant::expired(const struct timeval& now) {
|
|
|
|
|
if (Finished != status)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (WebConferenceFactory::ParticipantExpiredDelay < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
struct timeval diff;
|
|
|
|
|
timersub(&now,&last_access_time,&diff);
|
|
|
|
|
return (diff.tv_sec > 0) &&
|
|
|
|
|
(unsigned int)diff.tv_sec > PARTICIPANT_EXPIRED_DELAY;
|
|
|
|
|
(unsigned int)diff.tv_sec > (unsigned int)WebConferenceFactory::ParticipantExpiredDelay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AmArg ConferenceRoomParticipant::asArgArray() {
|
|
|
|
|
@ -33,26 +38,34 @@ void ConferenceRoomParticipant::setMuted(int mute) {
|
|
|
|
|
|
|
|
|
|
void ConferenceRoomParticipant::updateStatus(ConferenceRoomParticipant::ParticipantStatus
|
|
|
|
|
new_status,
|
|
|
|
|
const string& reason) {
|
|
|
|
|
const string& reason,
|
|
|
|
|
struct timeval& now) {
|
|
|
|
|
status = new_status;
|
|
|
|
|
last_reason = reason;
|
|
|
|
|
struct timeval now;
|
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
|
updateAccess(now);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConferenceRoom::ConferenceRoom() {
|
|
|
|
|
gettimeofday(&last_access_time, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConferenceRoom::cleanExpired() {
|
|
|
|
|
struct timeval now;
|
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
|
|
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
|
bool is_updated = false;
|
|
|
|
|
|
|
|
|
|
list<ConferenceRoomParticipant>::iterator it=participants.begin();
|
|
|
|
|
while (it != participants.end()) {
|
|
|
|
|
if (it->expired(now)) {
|
|
|
|
|
participants.erase(it);
|
|
|
|
|
it=participants.begin();
|
|
|
|
|
is_updated = true;
|
|
|
|
|
} else
|
|
|
|
|
it++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_updated)
|
|
|
|
|
memcpy(&last_access_time, &now, sizeof(struct timeval));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AmArg ConferenceRoom::asArgArray() {
|
|
|
|
|
@ -69,6 +82,8 @@ AmArg ConferenceRoom::asArgArray() {
|
|
|
|
|
|
|
|
|
|
void ConferenceRoom::newParticipant(const string& localtag,
|
|
|
|
|
const string& number) {
|
|
|
|
|
gettimeofday(&last_access_time, NULL);
|
|
|
|
|
|
|
|
|
|
participants.push_back(ConferenceRoomParticipant());
|
|
|
|
|
participants.back().localtag = localtag;
|
|
|
|
|
participants.back().number = number;
|
|
|
|
|
@ -87,6 +102,8 @@ bool ConferenceRoom::hasParticipant(const string& localtag) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConferenceRoom::setMuted(const string& localtag, int mute) {
|
|
|
|
|
gettimeofday(&last_access_time, NULL);
|
|
|
|
|
|
|
|
|
|
for (list<ConferenceRoomParticipant>::iterator it =participants.begin();
|
|
|
|
|
it != participants.end();it++)
|
|
|
|
|
if (it->localtag == localtag) {
|
|
|
|
|
@ -98,11 +115,13 @@ void ConferenceRoom::setMuted(const string& localtag, int mute) {
|
|
|
|
|
bool ConferenceRoom::updateStatus(const string& part_tag,
|
|
|
|
|
ConferenceRoomParticipant::ParticipantStatus newstatus,
|
|
|
|
|
const string& reason) {
|
|
|
|
|
gettimeofday(&last_access_time, NULL);
|
|
|
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
|
for (list<ConferenceRoomParticipant>::iterator it=participants.begin();
|
|
|
|
|
it != participants.end(); it++) {
|
|
|
|
|
if (it->localtag == part_tag) {
|
|
|
|
|
it->updateStatus(newstatus, reason);
|
|
|
|
|
it->updateStatus(newstatus, reason, last_access_time);
|
|
|
|
|
res = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
@ -112,3 +131,21 @@ bool ConferenceRoom::updateStatus(const string& part_tag,
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ConferenceRoom::expired() {
|
|
|
|
|
struct timeval now;
|
|
|
|
|
gettimeofday(&now, NULL);
|
|
|
|
|
return expired(now);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ConferenceRoom::expired(const struct timeval& now) {
|
|
|
|
|
if (!participants.empty())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (WebConferenceFactory::RoomExpiredDelay < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
struct timeval diff;
|
|
|
|
|
timersub(&now,&last_access_time,&diff);
|
|
|
|
|
return (diff.tv_sec > 0) &&
|
|
|
|
|
(unsigned int)diff.tv_sec > (unsigned int)WebConferenceFactory::RoomExpiredDelay;
|
|
|
|
|
}
|
|
|
|
|
|