Author: derek Date: Mon Jul 7 23:54:03 2008 New Revision: 426 Modified: sofaswitch/trunk/voip/jocall.h sofaswitch/trunk/voip/main.cxx sofaswitch/trunk/voip/mymanager.cxx sofaswitch/trunk/voip/mymanager.h sofaswitch/trunk/voip/supervisor.cxx Log: Get information for status improved. Can query the status of nodes which have disconnected from the message server, but are still in the aplication. Get the setting of id and server to work correctly. Modified: sofaswitch/trunk/voip/jocall.h ============================================================================== --- sofaswitch/trunk/voip/jocall.h (original) +++ sofaswitch/trunk/voip/jocall.h Mon Jul 7 23:54:03 2008 @@ -160,6 +160,9 @@ /**Get information (in a textual form) of how long this call has been up */ PString GetDurationInfo(); + /**Report from the comms instance on what it thinks about status */ + PString GetCommsStatusInfo() { return comms.GetStatusInfo(); } + /**Get a pointer to the PUDPSocket used by this particular call for audio datas */ PUDPSocket & GetAudioSocket(); Modified: sofaswitch/trunk/voip/main.cxx ============================================================================== --- sofaswitch/trunk/voip/main.cxx (original) +++ sofaswitch/trunk/voip/main.cxx Mon Jul 7 23:54:03 2008 @@ -247,8 +247,8 @@ // Create the Opal Manager and initialise it PString server; - if (args.HasOption("s")) { - server = args.GetOptionString("s"); + if (args.HasOption('s')) { + server = args.GetOptionString('s'); PTRACE(3, "server is " << server); } else { server = "localhost"; @@ -256,13 +256,15 @@ } PString ourId; - if (args.HasOption("id")) { - ourId = args.GetOptionString("id"); + if (args.HasOption('i')) { + ourId = args.GetOptionString('i'); PTRACE(3, "our ID is " << ourId); } else { ourId = "voip"; PTRACE(3, "Select a default ID of " << ourId); } + cerr << "Select ID of " << ourId << endl; + cerr << "Select a server of " << server << endl; ourId = server + "/" + ourId; Modified: sofaswitch/trunk/voip/mymanager.cxx ============================================================================== --- sofaswitch/trunk/voip/mymanager.cxx (original) +++ sofaswitch/trunk/voip/mymanager.cxx Mon Jul 7 23:54:03 2008 @@ -474,15 +474,15 @@ PTRACE(3, "Accept/Reject this call as we have found it " << uniqueCallId); call->AcceptThisCall(doAccept); } - -PString MyManager::GetStatusInfo(const PString & token) + + PString MyManager::GetStatusInfo(const PString & token) { - + PSafePtr<OpalCall> call = FindCallWithLock(token); if (call == NULL) { return "Status unavailable as not in a call"; } - + PStringStream status; status << call->GetPartyA() << "-" << call->GetPartyB() << endl; status << (PTime() - call->GetStartTime()) << " duration" << endl; @@ -491,6 +491,44 @@ return status; } +PString MyManager::GetStatusInfoSofaSwitchNode(const PString & token) +{ + PStringArray prebuilts = runningComms.GetCurrentEntries(); + PStringArray pendingNames = nodesMakingCalls.GetCurrentEntries(); + PSortedStringList currentNames = GetCurrentNames(); + PStringStream answer; + + if (prebuilts.GetStringsIndex(token) != P_MAX_INDEX) { + answer << "Found sofaswitch token " << token + << " in the list for precall nodes " << endl; + return answer; + } + + if (pendingNames.GetStringsIndex(token) != P_MAX_INDEX) { + answer << "Found sofaswitch token " << token + << " in the list for nodes in the process of making a call" << endl; + return answer; + } + + if (currentNames.GetStringsIndex(token) != P_MAX_INDEX) { + answer << "Found sofaswitch token " << token + << " in the list for nodes in a call. Now, get more detail." << endl; + + for (PSafePtr<OpalCall>call = activeCalls; call != NULL; ++call) { + MyOpalCall *c = PSafePtrCast<OpalCall, MyOpalCall>(call); + if (c != NULL) { + if (c->GetOurId() == token) { + answer << GetStatusInfo(c->GetToken()); + answer << c->GetCommsStatusInfo(); + return answer; + } + } + } + } + answer << "Did not find SofaSwitch node " << token << " on this voip server" << endl; + return answer; +} + PString MyManager::GetStatusInfo() { PStringStream status; @@ -536,14 +574,8 @@ status << endl; } - PSortedStringList currentNames; - for (PSafePtr<OpalCall>call = activeCalls; call != NULL; ++call) { - MyOpalCall *c = PSafePtrCast<OpalCall, MyOpalCall>(call); - if (c != NULL) - currentNames.AppendString(c->GetOurId()); - else - currentNames.AppendString("No name - weird"); - } + PSortedStringList currentNames = GetCurrentNames(); + if (currentNames.GetSize() > 0) { status << "Current active calls " << endl; @@ -555,6 +587,21 @@ return status; } +PSortedStringList MyManager::GetCurrentNames() +{ + PSortedStringList answer; + + for (PSafePtr<OpalCall>call = activeCalls; call != NULL; ++call) { + MyOpalCall *c = PSafePtrCast<OpalCall, MyOpalCall>(call); + if (c != NULL) + answer.AppendString(c->GetOurId()); + else + answer.AppendString("No name - weird"); + } + return answer; +} + + Comms * MyManager::ClearCommsId(const PString &memberId) { PTRACE(3, "Clear comms Id on " << memberId); Modified: sofaswitch/trunk/voip/mymanager.h ============================================================================== --- sofaswitch/trunk/voip/mymanager.h (original) +++ sofaswitch/trunk/voip/mymanager.h Mon Jul 7 23:54:03 2008 @@ -173,9 +173,13 @@ virtual void DestroyCall(OpalCall * call); /**Request manager to provide status information on the call - matching this specific token */ + matching this specific token. This token is the opal call token. */ PString GetStatusInfo(const PString & token); + /**Request manager to provide status information on the call + matching this specific token. This token is the sofaSwitch token. */ + PString GetStatusInfoSofaSwitchNode(const PString & token); + /**Request manager to provide general status information on all calls */ PString GetStatusInfo(); @@ -221,6 +225,10 @@ CommsConsumer class to remove this instance */ void AppendFinishedComms(Comms *commsPtr); + /**Report, in a sorted string list, the sofa id of all running + comms instances in a call */ + PSortedStringList GetCurrentNames(); + protected: /**The interface to the external script which runs python, to provide comms for us */ LaunchNewId &lid; Modified: sofaswitch/trunk/voip/supervisor.cxx ============================================================================== --- sofaswitch/trunk/voip/supervisor.cxx (original) +++ sofaswitch/trunk/voip/supervisor.cxx Mon Jul 7 23:54:03 2008 @@ -104,8 +104,12 @@ void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender) { - PString status; - status = VoipProcess::Current().GetManager()->GetStatusInfo(); + PStringStream status; + if (cmds.GetSize() >= 2) { + for (PINDEX i = 1; i < cmds.GetSize(); i++) + status << VoipProcess::Current().GetManager()->GetStatusInfoSofaSwitchNode(cmds[i]); + } else + status << VoipProcess::Current().GetManager()->GetStatusInfo(); SendThisMessageTo(status, sender); }