]> git.vomp.tv Git - vompserver.git/commitdiff
*** empty log message ***
authorChris Tallon <chris@vomp.tv>
Sat, 17 Oct 2009 16:46:56 +0000 (16:46 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 17 Oct 2009 16:46:56 +0000 (16:46 +0000)
vompclient.c
vompclient.h
vompclientrrproc.c

index acfa62be42d9611af6f840eedc7272dfe97d12eb..fd8baf537c87171a8ceb2c24cb674bf06183d0a3 100644 (file)
@@ -55,6 +55,7 @@ VompClient::VompClient(Config* cfgBase, char* tconfigDir, int tsocket)
   incClients();
   media=new MediaPlayer();
   mediaprovider=new ServerMediaFile(cfgBase,media);
+  netLogFile = NULL;
   
   rrproc.init();
 }
@@ -83,6 +84,12 @@ VompClient::~VompClient()
   
   delete media;
   delete mediaprovider;
+  
+  if (netLogFile)
+  {
+    fclose(netLogFile);
+    netLogFile = NULL;
+  }
 }
 
 void VompClient::incClients()
@@ -145,6 +152,31 @@ void VompClient::cleanConfig()
 #endif
 } */
 
+void VompClient::netLog()
+{
+  // Hook, called from rrproc login after client has logged in.
+  // See if this MVP config says to do network logging, if so open a log
+  // The config object will be usable now since it's set up in login
+  
+  char* doNetLogging = config.getValueString("Advanced", "Network logging");
+  if (doNetLogging)
+  {
+    if (!strcasecmp(doNetLogging, "on"))
+    {
+      char* netLogFileName = config.getValueString("Advanced", "Network logging file");
+      if (netLogFileName)
+      {
+        netLogFile = fopen(netLogFileName, "a");
+        if (netLogFile) log->log("Client", Log::DEBUG, "Client network logging started");
+
+        delete[] netLogFileName;
+      }
+    }
+    
+    delete[] doNetLogging;
+  }
+}
+
 void VompClientStartThread(void* arg)
 {
   VompClient* m = (VompClient*)arg;
@@ -182,6 +214,7 @@ void VompClient::run2()
   UCHAR* data;
   
   ULONG kaTimeStamp;
+  ULONG logStringLen;
 
   while(1)
   {
@@ -265,6 +298,27 @@ void VompClient::run2()
         break;
       }      
     }
+    else if (channelID == 4)
+    {
+      if (!tcp.readData((UCHAR*)&logStringLen, sizeof(ULONG))) break;
+      logStringLen = ntohl(logStringLen);
+
+      log->log("Client", Log::DEBUG, "Received chan=%lu loglen=%lu", channelID, logStringLen);    
+
+      UCHAR buffer[logStringLen + 1];
+      if (!tcp.readData((UCHAR*)&buffer, logStringLen)) break;
+      buffer[logStringLen] = '\0';
+
+//      log->log("Client", Log::INFO, "Client said: '%s'", buffer);
+      if (netLogFile)
+      {
+        if (fputs((const char*)buffer, netLogFile) == EOF)
+        {
+          fclose(netLogFile);
+          netLogFile = NULL;
+        }
+      }
+    }    
     else
     {
       log->log("Client", Log::ERR, "Incoming channel number unknown");
index bd43790640accb95acd3b89c717850fa71ead44b..a7b0bf0b0daa1f622b6e37c1b3a603160d9a6bd4 100644 (file)
@@ -95,6 +95,9 @@ class VompClient
     bool loggedIn;
     char* configDir;
 
+    void netLog();
+    FILE* netLogFile;
+
     //void cleanConfig();
 
 #ifndef VOMPSTANDALONE
index 9477d09f4323e7842d061db1e14e12880dac664e..ce9cc115c27b292fc5c36c1c84cf305071bef74f 100644 (file)
@@ -275,6 +275,8 @@ int VompClientRRProc::processLogin()
   log->log("RRProc", Log::DEBUG, "written login reply len %lu", resp->getLen());
     
   x.loggedIn = true;
+  x.netLog(); // safe to run here since the client won't start net logging for a while yet
+  
   return 1;
 }