[Live-devel] Knowing when a client session is cleaned up?
Craig Matsuura
cmatsuura at vivint.com
Fri Aug 19 10:30:08 PDT 2016
Ross,
We are wanting to know when a session is cleaned up. I found the livenessTimoutTask is called when the reclaim timer expires, but I can not get to it from a sub-class. I also see the new noteLiveness() override in the ServerMediaSession. Instead of me tracking my own liveness, I added an livenessTimeouTask() to the ServerMediaSession (just like the noteLiveness) so I can be informed of the session that was cleaned up. So in the GenericMediaServer I added a call to the livenesstimeoutTask() in the ServerMediaSession (just like you did for noteLiveness). I pass the session id and streamname. Is there a different way to do this? If not would it be possible to get this in to future source?
Here is my patch:
diff -r 9e993be31201 liveMedia/GenericMediaServer.cpp
--- a/liveMedia/GenericMediaServer.cpp Wed Aug 17 13:52:57 2016 -0600
+++ b/liveMedia/GenericMediaServer.cpp Fri Aug 19 11:26:39 2016 -0600
@@ -302,12 +302,17 @@
void GenericMediaServer::ClientSession::livenessTimeoutTask(ClientSession* clientSession) {
// If this gets called, the client session is assumed to have timed out, so delete it:
-#ifdef DEBUG
char const* streamName
= (clientSession->fOurServerMediaSession == NULL) ? "???" : clientSession->fOurServerMediaSession->streamName();
+#ifdef DEBUG
fprintf(stderr, "Client session (id \"%08X\", stream name \"%s\") has timed out (due to inactivity)\n",
clientSession->fOurSessionId, streamName);
#endif
+ // If we have a media session we can call the livenessTimeoutTask for that media session
+ // This is similar to the noteLiveness()
+ if (clientSession->fOurServerMediaSession != NULL) {
+ clientSession->fOurServerMediaSession->livenessTimeoutTask(clientSession->fOurSessionId, streamName);
+ }
delete clientSession;
}
diff -r 9e993be31201 liveMedia/ServerMediaSession.cpp
--- a/liveMedia/ServerMediaSession.cpp Wed Aug 17 13:52:57 2016 -0600
+++ b/liveMedia/ServerMediaSession.cpp Fri Aug 19 11:26:39 2016 -0600
@@ -198,6 +198,11 @@
// default implementation: do nothing
}
+void ServerMediaSession::livenessTimeoutTask(u_int32_t sessionId, char const *streamName) {
+ // default implementation: do nothing
+}
+
+
void ServerMediaSession::deleteAllSubsessions() {
Medium::close(fSubsessionsHead);
fSubsessionsHead = fSubsessionsTail = NULL;
diff -r 9e993be31201 liveMedia/include/ServerMediaSession.hh
--- a/liveMedia/include/ServerMediaSession.hh Wed Aug 17 13:52:57 2016 -0600
+++ b/liveMedia/include/ServerMediaSession.hh Fri Aug 19 11:26:39 2016 -0600
@@ -62,6 +62,11 @@
// The default implementation does nothing, but subclasses can redefine this - e.g., if you
// want to remove long-unused "ServerMediaSession"s from the server.
+ virtual void livenessTimeoutTask(u_int32_t sessionId, char const *streamName);
+ // called when a client is cleaned up due to the timeout expiring
+ // The default implementation does nothing, but subclasses can redefine this - e.g., if you
+ // want to know if long-unused "ServerMediaSession"s is removed sub-class this method.
+
unsigned referenceCount() const { return fReferenceCount; }
void incrementReferenceCount() { ++fReferenceCount; }
void decrementReferenceCount() { if (fReferenceCount > 0) --fReferenceCount; }
Thanks,
Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20160819/39a20b8f/attachment.html>
More information about the live-devel
mailing list