[Sofaswitch-svn] [commit] r433 - in sofaswitch/trunk: am mcu sofa/include/sofa sofa/src voip
Author: derek Date: Sun Jul 27 00:47:16 2008 New Revision: 433 Modified: sofaswitch/trunk/am/comms.cxx sofaswitch/trunk/am/comms.h sofaswitch/trunk/am/manager.cxx sofaswitch/trunk/am/manager.h sofaswitch/trunk/am/supervisor.cxx sofaswitch/trunk/am/supervisor.h sofaswitch/trunk/mcu/comms.cxx sofaswitch/trunk/mcu/comms.h sofaswitch/trunk/mcu/conferenceroom.cxx sofaswitch/trunk/mcu/conferenceroom.h sofaswitch/trunk/mcu/manager.cxx sofaswitch/trunk/mcu/manager.h sofaswitch/trunk/mcu/supervisor.cxx sofaswitch/trunk/mcu/supervisor.h sofaswitch/trunk/sofa/include/sofa/messages.h sofaswitch/trunk/sofa/src/messages.cxx sofaswitch/trunk/voip/comms.cxx sofaswitch/trunk/voip/comms.h sofaswitch/trunk/voip/mymanager.cxx sofaswitch/trunk/voip/mymanager.h sofaswitch/trunk/voip/supervisor.cxx sofaswitch/trunk/voip/supervisor.h Log: Big tidy up. Move all comamnd handling to use Const, so that the strings are handled as efficiently as possible. Modified: sofaswitch/trunk/am/comms.cxx ============================================================================== --- sofaswitch/trunk/am/comms.cxx (original) +++ sofaswitch/trunk/am/comms.cxx Sun Jul 27 00:47:16 2008 @@ -72,7 +72,7 @@ new CommsConsumer(manager, this); } -void Comms::ProcessTransferUdp(PStringArray &cmds, PString & sender) +void Comms::ProcessTransferUdp(const PStringArray &cmds, const PString & sender) { PTRACE(3, "Comms::ProcessTransferUdp " << cmds); @@ -143,7 +143,7 @@ createdAt = PTime(); } -void Comms::ProcessHangup(PStringArray &cmds, PString & sender) +void Comms::ProcessHangup(const PStringArray &cmds, const PString & sender) { SilentlyEndAll(); } @@ -158,12 +158,12 @@ } -void Comms::ProcessCallNode(PStringArray &cmds, PString & sender) +void Comms::ProcessCallNode(const PStringArray &cmds, const PString & sender) { // manager.StartCall(cmds[1], sender, GetOurId()); } -void Comms::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void Comms::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { PTRACE(3, "Coms::ProcessStatusQuery"); @@ -205,25 +205,25 @@ return duration; } -void Comms::ProcessDuration(PStringArray &cmds, PString & sender) +void Comms::ProcessDuration(const PStringArray &cmds, const PString & sender) { PString duration = GetDurationInfo(); SendThisMessageTo(duration, sender); } -void Comms::ProcessIdentify(PStringArray &cmds, PString & sender) +void Comms::ProcessIdentify(const PStringArray &cmds, const PString & sender) { PStringStream message; message << "Sofa Switch Answering Machine for call " + GetOurId(); SendThisMessageTo(message, sender); } -void Comms::ProcessDebug(PStringArray &cmds, PString & sender) +void Comms::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" debug on/off"), sender); } -void Comms::ProcessAnswer(PStringArray &cmds, PString & sender) +void Comms::ProcessAnswer(const PStringArray &cmds, const PString & sender) { PTRACE(3, "We answer this call automatically, so thankyou"); } Modified: sofaswitch/trunk/am/comms.h ============================================================================== --- sofaswitch/trunk/am/comms.h (original) +++ sofaswitch/trunk/am/comms.h Sun Jul 27 00:47:16 2008 @@ -110,32 +110,32 @@ transferred, we move ourselves out of the Manager's list of pending calls. Then we call the ancestor method to actually do the work of transferring the udp */ - virtual void ProcessTransferUdp(PStringArray &cmds, PString & sender); + virtual void ProcessTransferUdp(const PStringArray &cmds, const PString & sender); /**we have received a hangup message, so end the call */ - virtual void ProcessHangup(PStringArray &cmds, PString & sender); + virtual void ProcessHangup(const PStringArray &cmds, const PString & sender); /**we have received a Call other Node command, so do it and reply accordingly*/ - virtual void ProcessCallNode(PStringArray &cmds, PString & sender); + virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly*/ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**we have received a command queryig the current call duration , so extract information & answer */ - virtual void ProcessDuration(PStringArray &cmds, PString & sender); + virtual void ProcessDuration(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us how to answer to the incoming call, so we act as required and reply accordingly*/ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender); + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender); /**Send this dtmf string to the remote node. Returns true on success, false on failure. */ Modified: sofaswitch/trunk/am/manager.cxx ============================================================================== --- sofaswitch/trunk/am/manager.cxx (original) +++ sofaswitch/trunk/am/manager.cxx Sun Jul 27 00:47:16 2008 @@ -121,15 +121,21 @@ supervisor.WaitForTermination(); } -void Manager::RequestNewId(const PString & requester) +void Manager::RequestNewId(const PStringArray & cmds, + const PString & requester) { Comms *c = runningComms->GetNextComms(); - if (c == NULL) - return; + if (c == NULL) { + PStringStream msg; + msg << cmds[0] << " failed as could not get the next comms to use"; + supervisor.SendThisMessageTo(msg, requester); + return; + } c->SetRemoteController(requester); nodesMakingCalls.AddNewMessageFrame(c); - supervisor.SendThisMessageTo(PString("REQUESTNEWID ") + c->GetOurId(), requester); + supervisor.SendThisMessageTo(cmds[0] + PString(" ") + c->GetOurId(), + requester); } Comms * Manager::RemoveFromPreCallQueue(const PString & preferredId) Modified: sofaswitch/trunk/am/manager.h ============================================================================== --- sofaswitch/trunk/am/manager.h (original) +++ sofaswitch/trunk/am/manager.h Sun Jul 27 00:47:16 2008 @@ -104,7 +104,7 @@ /**Allocate a new ID, place it in the pending list (nodesMakingNewCalls) and reply with the id to the controller who made this request */ - void RequestNewId(const PString & requester); + void RequestNewId(const PStringArray & cmds, const PString & requester); /**The entry point, where the main control loop sits */ void Main(); Modified: sofaswitch/trunk/am/supervisor.cxx ============================================================================== --- sofaswitch/trunk/am/supervisor.cxx (original) +++ sofaswitch/trunk/am/supervisor.cxx Sun Jul 27 00:47:16 2008 @@ -59,7 +59,7 @@ PTRACE(3, "end of this supervisor "); } -void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender) +void Supervisor::ProcessAnswer(const PStringArray &cmds, const PString & sender) { PTRACE(0, "Should not called in the context of an AM"); } @@ -73,7 +73,7 @@ PTRACE(3, "Destructor Supervisor thread has ended"); } -void Supervisor::ProcessCallNode(PStringArray & cmds, PString & sender) +void Supervisor::ProcessCallNode(const PStringArray & cmds, const PString & sender) { PTRACE(3, "Supervisor:: we can start a call to " << sender); if (cmds.GetSize() < 2) { @@ -83,7 +83,7 @@ } } -void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void Supervisor::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { Manager *mgr = AmProcess::Current().GetManager(); PStringStream status; @@ -104,17 +104,17 @@ } -void Supervisor::ProcessIdentify(PStringArray &cmds, PString & sender) +void Supervisor::ProcessIdentify(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" We are the supervisor for the Sofa Switch Answering Machine"), sender); } -void Supervisor::ProcessDebug(PStringArray &cmds, PString & sender) +void Supervisor::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" debug on/off"), "", sender); } -void Supervisor::ProcessQuitNow(PStringArray &cmds, PString & sender) +void Supervisor::ProcessQuitNow(const PStringArray &cmds, const PString & sender) { SetRemoteController(sender); PTRACE(3, "Supervisor says::End everything now"); @@ -122,9 +122,9 @@ PTRACE(3, "Supervisor says::End everything now, and it has been initiated."); } -void Supervisor::ProcessRequestNewId(PStringArray &/*cmds*/, PString & sender) +void Supervisor::ProcessRequestNewId(const PStringArray & cmds, const PString & sender) { - AmProcess::Current().GetManager()->RequestNewId(sender); + AmProcess::Current().GetManager()->RequestNewId(cmds, sender); } void Supervisor::SilentlyEndAll() Modified: sofaswitch/trunk/am/supervisor.h ============================================================================== --- sofaswitch/trunk/am/supervisor.h (original) +++ sofaswitch/trunk/am/supervisor.h Sun Jul 27 00:47:16 2008 @@ -63,7 +63,7 @@ protected: /**we have received a command advising us how to answer to the incoming call, so we act as required and reply accordingly*/ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender); + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender); /**The supervisor has completed. This method is called when this supervisor instance terminates. Since there is only one @@ -72,26 +72,26 @@ /**we have received a Call other Node command, so do it and reply accordingly*/ - virtual void ProcessCallNode(PStringArray & cmds, PString & sender); + virtual void ProcessCallNode(const PStringArray & cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly*/ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us that we are to end now */ - virtual void ProcessQuitNow(PStringArray &cmds, PString & sender); + virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to provide the id of a new communications nodes, that will be controlled only by the remote node */ - virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender); + virtual void ProcessRequestNewId(const PStringArray &cmds, const PString & sender); /**Some MessageFrame instances do not have the permission to quit now. This virtual method determines if this instance is permitted to Modified: sofaswitch/trunk/mcu/comms.cxx ============================================================================== --- sofaswitch/trunk/mcu/comms.cxx (original) +++ sofaswitch/trunk/mcu/comms.cxx Sun Jul 27 00:47:16 2008 @@ -66,7 +66,7 @@ new CommsConsumer(manager, this); } -void Comms::ProcessTransferUdp(PStringArray &cmds, PString & sender) +void Comms::ProcessTransferUdp(const PStringArray &cmds, const PString & sender) { PTRACE(3, "Set media connection pointer of comms to be frame "); @@ -88,7 +88,7 @@ SendThisMessageTo(advise, remoteController); } -void Comms::ProcessHangup(PStringArray &cmds, PString & sender) +void Comms::ProcessHangup(const PStringArray &cmds, const PString & sender) { /* First step in the destruction of this Comms instance. Note that there are two ways a comms instance can be closed down. @@ -132,7 +132,7 @@ audioWriteThread.Terminate(); } -void Comms::ProcessCallNode(PStringArray &cmds, PString & sender) +void Comms::ProcessCallNode(const PStringArray &cmds, const PString & sender) { PTRACE(3, "One Unqiue Id:: we can start a call (controlled by " << sender << ")"); if (cmds.GetSize() < 2) { @@ -144,7 +144,7 @@ // manager.StartCall(cmds[1], sender, GetOurId()); } -void Comms::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void Comms::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { PTRACE(3, "Coms::ProcessStatusQuery"); PSafePtr <Member> member = manager.activeMembers.FindWithLock(GetOurId(), PSafeReadOnly);; @@ -166,7 +166,7 @@ SendThisMessageTo(status, sender); } -void Comms::ProcessDuration(PStringArray &cmds, PString & sender) +void Comms::ProcessDuration(const PStringArray &cmds, const PString & sender) { PString duration = GetDurationInfo(); SendThisMessageTo(duration, sender); @@ -194,19 +194,19 @@ return member->GetDurationInfo(); } -void Comms::ProcessIdentify(PStringArray &cmds, PString & sender) +void Comms::ProcessIdentify(const PStringArray &cmds, const PString & sender) { PStringStream message; message << "Sofa Switch Answering Machine for call " + GetOurId(); SendThisMessageTo(message, sender); } -void Comms::ProcessDebug(PStringArray &cmds, PString & sender) +void Comms::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" debug on/off"), sender); } -void Comms::ProcessAnswer(PStringArray &cmds, PString & sender) +void Comms::ProcessAnswer(const PStringArray &cmds, const PString & sender) { PTRACE(3, "We answer this call automatically, so thankyou"); } Modified: sofaswitch/trunk/mcu/comms.h ============================================================================== --- sofaswitch/trunk/mcu/comms.h (original) +++ sofaswitch/trunk/mcu/comms.h Sun Jul 27 00:47:16 2008 @@ -101,13 +101,13 @@ transferred, we move ourselves out of the Manager's list of pending calls. Then we call the ancestor method to actually do the work of transferring the udp */ - virtual void ProcessTransferUdp(PStringArray &cmds, PString & sender); + virtual void ProcessTransferUdp(const PStringArray &cmds, const PString & sender); /**we have received a hangup message, so end the call */ - virtual void ProcessHangup(PStringArray &cmds, PString & sender); + virtual void ProcessHangup(const PStringArray &cmds, const PString & sender); /**we have received a Call other Node command, so do it and reply accordingly*/ - virtual void ProcessCallNode(PStringArray &cmds, PString & sender); + virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly. @@ -117,7 +117,7 @@ first structure may have changed. Consequently, it does happen where the counts of the instances of different classes is not consistant. */ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**Get information (in a textual form) of how long this call has been up */ PString GetDurationInfo(); @@ -128,19 +128,19 @@ /**we have received a command queryig the current call duration , so extract information & answer */ - virtual void ProcessDuration(PStringArray &cmds, PString & sender); + virtual void ProcessDuration(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us how to answer to the incoming call, so we act as required and reply accordingly*/ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender); + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender); /**Send this dtmf string to the remote node. Returns true on success, false on failure. */ Modified: sofaswitch/trunk/mcu/conferenceroom.cxx ============================================================================== --- sofaswitch/trunk/mcu/conferenceroom.cxx (original) +++ sofaswitch/trunk/mcu/conferenceroom.cxx Sun Jul 27 00:47:16 2008 @@ -43,7 +43,7 @@ PTRACE(3, "ConferenceRoom\tConstructor for " << *this); } -void ConferenceRoom::PrintOn(ostream & strm ) const +void ConferenceRoom::PrintOn(ostream & strm ) const { strm << "Conference Room " << roomId; } @@ -53,7 +53,7 @@ PTRACE(3, "ConferenceRoom\tDestructor for " << *this); } -void ConferenceRoom::RemoveMember(PString memberId) +void ConferenceRoom::RemoveMember(const PString & memberId) { PWaitAndSignal m(memberListLock); @@ -92,7 +92,7 @@ return participants; } -PStringList ConferenceRoom::AddNewMember(PString memberId) +PStringList ConferenceRoom::AddNewMember(const PString & memberId) { PTRACE(3, "Add member " << memberId << " to " << roomId); PWaitAndSignal m(memberListLock); Modified: sofaswitch/trunk/mcu/conferenceroom.h ============================================================================== --- sofaswitch/trunk/mcu/conferenceroom.h (original) +++ sofaswitch/trunk/mcu/conferenceroom.h Sun Jul 27 00:47:16 2008 @@ -76,12 +76,12 @@ PString GetRoomId() { return roomId; } /**Remove a member from this list of members */ - void RemoveMember(PString memberId); + void RemoveMember(const PString & memberId); /**Add a member to this list of members. @return the list of members in this room, prior to addition.*/ - PStringList AddNewMember(PString memberId); + PStringList AddNewMember(const PString & memberId); /**pretty print information this ConferenceRoom */ virtual void PrintOn(ostream & strm /// Stream to output text representation Modified: sofaswitch/trunk/mcu/manager.cxx ============================================================================== --- sofaswitch/trunk/mcu/manager.cxx (original) +++ sofaswitch/trunk/mcu/manager.cxx Sun Jul 27 00:47:16 2008 @@ -197,11 +197,10 @@ activeRooms.RemoveAt(conferenceRoomId); } -void Manager::RequestNewId(const PString & requester, PStringArray &cmd) +void Manager::RequestNewId(const PStringArray &cmd, const PString & requester) { PTRACE(3, "Manager\t request room " << cmd[1] << " and an id"); - PString roomId = cmd[1]; - + PString roomId = cmd[1]; { PWaitAndSignal m(activeRooms.GetMutex()); /**Prevent adding two conferences of same name */ PSafePtr <ConferenceRoom> room = activeRooms.FindWithLock(roomId, PSafeReadOnly); @@ -225,8 +224,9 @@ if (c == NULL) return; - /* The next line of code ensures there will be a message, generated by the server, - sent to the node specified in requester when c dies. */ + /* The next line of code ensures there will be a message, generated + by the server, sent to the node specified in requester when c + dies. */ c->SetRemoteController(requester); PTRACE(3, "Prior Create Member, size is " << activeMembers.GetSize()); @@ -239,8 +239,7 @@ PTRACE(3, "Have created member, " << c->GetOurId() << " and filled membership list"); nodesMakingCalls.AddNewMessageFrame(c); - supervisor.SendThisMessageTo(PString("REQUESTNEWID ") + c->GetOurId(), requester); - PTRACE(3, "Created Member, size is now " << activeMembers.GetSize()); + supervisor.SendThisMessageTo(cmd[0] + PString(" ") + c->GetOurId(), requester); } Comms * Manager::RemoveFromPreCallQueue(const PString & preferredId) @@ -270,7 +269,7 @@ return c; } -PString Manager::ProcessStatusQuery(PStringArray & cmds) +PString Manager::ProcessStatusQuery(const PStringArray & cmds) { PStringStream result; Modified: sofaswitch/trunk/mcu/manager.h ============================================================================== --- sofaswitch/trunk/mcu/manager.h (original) +++ sofaswitch/trunk/mcu/manager.h Sun Jul 27 00:47:16 2008 @@ -100,7 +100,8 @@ and reply with the id to the controller who made this request. Also causes a PSafePtr<Member> to be added to the activeMembers list in a threadsafe fashion. */ - void RequestNewId(const PString & requester, PStringArray & cmds); + void RequestNewId(const PStringArray & cmds, const PString & requester); + /**Cause the PSafePtr<Member> of the specified id to be removed from the * activeMembers list in a threadsafe fashion */ @@ -134,7 +135,7 @@ void WaitForSupervisorEnd(); /**Get the status on all conferences, or just one conference */ - PString ProcessStatusQuery(PStringArray & cmds); + PString ProcessStatusQuery(const PStringArray & cmds); /**Cause the comms instance in activeCalls to be removed from this list. This is an action which is part of the shut down Modified: sofaswitch/trunk/mcu/supervisor.cxx ============================================================================== --- sofaswitch/trunk/mcu/supervisor.cxx (original) +++ sofaswitch/trunk/mcu/supervisor.cxx Sun Jul 27 00:47:16 2008 @@ -55,7 +55,7 @@ PTRACE(3, "end of this supervisor "); } -void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender) +void Supervisor::ProcessAnswer(const PStringArray &cmds, const PString & sender) { PAssertAlways("ProcessAnswer Should not called in the context of an MCU"); } @@ -65,7 +65,7 @@ PTRACE(3, "Supervisor thread has ended"); } -void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void Supervisor::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { PString status; status = McuProcess::Current().GetManager()->ProcessStatusQuery(cmds); @@ -74,17 +74,17 @@ } -void Supervisor::ProcessIdentify(PStringArray &cmds, PString & sender) +void Supervisor::ProcessIdentify(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" We are the supervisor for the Sofa Switch Answering Machine"), sender); } -void Supervisor::ProcessDebug(PStringArray &cmds, PString & sender) +void Supervisor::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" debug on/off"), "", sender); } -void Supervisor::ProcessQuitNow(PStringArray &cmds, PString & sender) +void Supervisor::ProcessQuitNow(const PStringArray &cmds, const PString & sender) { SetRemoteController(sender); PTRACE(3, "Supervisor says::End everything now"); @@ -92,27 +92,23 @@ } -void Supervisor::ProcessHangup(PStringArray &cmds, PString & sender) +void Supervisor::ProcessHangup(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" is not handled by the supervisor - send it to the relevant call "), sender); } -void Supervisor::ProcessRequestNewId(PStringArray & cmds, PString & sender) +void Supervisor::ProcessRequestNewId(const PStringArray & cmds, const PString & sender) { - PStringStream commands; - for (PINDEX i = 0; i < cmds.GetSize(); i++) - commands << cmds[i] << " "; - PTRACE(3, "Supervisor:ProcessRequestNewId :: " << commands); - if (cmds.GetSize() < 2) { PStringStream strm; - strm << cmds; - PTRACE(3, "Ignore this request new id as no room specified " << strm); + strm << "Ignore this request new id as no room specified " << cmds; + SendThisMessageTo(strm, sender); + PTRACE(3, strm); return; } - McuProcess::Current().GetManager()->RequestNewId(sender, cmds); + McuProcess::Current().GetManager()->RequestNewId(cmds, sender); } void Supervisor::SilentlyEndAll() Modified: sofaswitch/trunk/mcu/supervisor.h ============================================================================== --- sofaswitch/trunk/mcu/supervisor.h (original) +++ sofaswitch/trunk/mcu/supervisor.h Sun Jul 27 00:47:16 2008 @@ -64,7 +64,7 @@ call, so we act as required and reply accordingly. The mcu does not actually handle this at the moment. We are required to declare this method, as ProcessAnswer is pure, in the ancestor.*/ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender); + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender); /**The supervisor has completed. This method is called when this supervisor instance terminates. Since there is only one @@ -72,7 +72,7 @@ virtual void OnTermination(); /**we have received a hangup message, so end the call */ - virtual void ProcessHangup(PStringArray &cmds, PString & sender); + virtual void ProcessHangup(const PStringArray &cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly @@ -82,23 +82,23 @@ first structure may have changed. Consequently, it does happen where the counts of the instances of different classes is not consistant. */ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us that we are to end now */ - virtual void ProcessQuitNow(PStringArray &cmds, PString & sender); + virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to provide the id of a new communications nodes, that will be controlled only by the remote node */ - virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender); + virtual void ProcessRequestNewId(const PStringArray &cmds, const PString & sender); /**Some MessageFrame instances do not have the permission to quit now. This virtual method determines if this instance is permitted to Modified: sofaswitch/trunk/sofa/include/sofa/messages.h ============================================================================== --- sofaswitch/trunk/sofa/include/sofa/messages.h (original) +++ sofaswitch/trunk/sofa/include/sofa/messages.h Sun Jul 27 00:47:16 2008 @@ -167,47 +167,47 @@ /**We have a message come in from the server, and it ends up here. Now, handle this message, and give it to the relevant method below */ - virtual void ProcessMessage(PString & message, - PString & sender); + virtual void ProcessMessage(const PString & message, + const PString & sender); /**we have received a hangup message, so end the call */ - virtual void ProcessHangup(PStringArray &cmds, PString & sender); + virtual void ProcessHangup(const PStringArray &cmds, const PString & sender); /**we have received a Call other Node command, so do it and reply accordingly*/ - virtual void ProcessCallNode(PStringArray &cmds, PString & sender); + virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly*/ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**we have received a Query Local Address & port command, so reply accordingly*/ - virtual void ProcessQueryLocalAddress(PStringArray &cmds, PString & sender); + virtual void ProcessQueryLocalAddress(const PStringArray &cmds, const PString & sender); /**we have received a Query on the Destination Address & port, so reply accordingly*/ - virtual void ProcessQueryDestAddress(PStringArray &cmds, PString & sender); + virtual void ProcessQueryDestAddress(const PStringArray &cmds, const PString & sender); /**we have received a command advising us of the address & port to send to, so store this information and reply accordingly*/ - virtual void ProcessAdviseSendAddress(PStringArray &cmds, PString & sender); + virtual void ProcessAdviseSendAddress(const PStringArray &cmds, const PString & sender); /**we have received a command queryig the current call duration , so extract information & answer */ - virtual void ProcessDuration(PStringArray &cmds, PString & sender); + virtual void ProcessDuration(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us how to answer to the incoming call, so we act as required and reply accordingly*/ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender) = 0; + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender) = 0; /**we have received a command advising us that we are to install udp comms with a particular remote node id. Now, we have to reply @@ -224,29 +224,29 @@ Although, a supervisor, which watchs lots of calls, will override this and treat it as an error on receiving this comand.*/ - virtual void ProcessTransferUdp(PStringArray &cmds, PString & sender); + virtual void ProcessTransferUdp(const PStringArray &cmds, const PString & sender); /**we have received a command advising us that we are to end now */ - virtual void ProcessQuitNow(PStringArray &cmds, PString & sender); + virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to list the available commands */ - virtual void ProcessHelp(PStringArray &cmds, PString & sender); + virtual void ProcessHelp(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to send the dtmf chars. An application would not normally override this method.*/ - virtual void ProcessSendDtmf(PStringArray &cmds, PString & sender); + virtual void ProcessSendDtmf(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to provide the id of a new communications nodes, that will be controlled only by the remote node */ - virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender); + virtual void ProcessRequestNewId(const PStringArray &cmds, const PString & sender); /**We have received a command asking us to set the file that we fill with audio data. This file will (normally) be empty. An application would not override this method, as this mthod does check that a file name is provided. This method will call SetReadFile, which the application will override */ - virtual void ProcessSetWriteFile(PStringArray &cmds, const PString & sender); + virtual void ProcessSetWriteFile(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to set the file that we read from and then transmit over ethernet to the remote @@ -255,14 +255,14 @@ method, as this mthod does check that a file name is provided. This method will call SetWriteFile, which the application will override */ - virtual void ProcessSetReadFile(PStringArray &cmds, const PString & sender); + virtual void ProcessSetReadFile(const PStringArray &cmds, const PString & sender); #ifdef PMEMORY_CHECK /**we have received a command asking us to write all current allocations to the specified file. This command checks the the file is specified in the command line. If specified, all objects are dumped to that file.*/ - virtual void ProcessMemoryDump(PStringArray &cmds, PString & sender); + virtual void ProcessMemoryDump(const PStringArray &cmds, const PString & sender); #endif /**Actually set the file that we write audio to. We will fill this Modified: sofaswitch/trunk/sofa/src/messages.cxx ============================================================================== --- sofaswitch/trunk/sofa/src/messages.cxx (original) +++ sofaswitch/trunk/sofa/src/messages.cxx Sun Jul 27 00:47:16 2008 @@ -433,8 +433,8 @@ writeMessageLock.Signal(); } -void MessageFrame::ProcessMessage(PString & message, - PString & sender) +void MessageFrame::ProcessMessage(const PString & message, + const PString & sender) { lastSender = sender; PStringArray cmds = message.Tokenise(" ", false); @@ -537,7 +537,9 @@ return; } - if (cmds[0] *= availableCommands[14]) { + /* The RequestNewId command can come as REQUESTNEWID_IdentityString, + where the IdentityString labels where the newid answer is handled*/ + if (cmds[0].Left(12) *= availableCommands[14]) { PTRACE(4, "ProcessRequestNewId " << cmds[0]); ProcessRequestNewId(cmds, sender); return; @@ -572,22 +574,22 @@ PTRACE(3, PString("The command ") + cmds[0] + " was not understood"); } -void MessageFrame::ProcessHangup(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessHangup(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } -void MessageFrame::ProcessCallNode(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessCallNode(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } -void MessageFrame::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } -void MessageFrame::ProcessQueryLocalAddress(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessQueryLocalAddress(const PStringArray &cmds, const PString & sender) { PINDEX portNo; PIPSocket::Address addr; @@ -599,7 +601,7 @@ SendThisMessageTo(cmds[0] + PString(" ") + addr.AsString() + PString(":") + PString(portNo), sender); } -void MessageFrame::ProcessQueryDestAddress(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessQueryDestAddress(const PStringArray &cmds, const PString & sender) { PINDEX portNo; PIPSocket::Address addr; @@ -611,7 +613,7 @@ SendThisMessageTo(cmds[0] + PString(" ") + addr.AsString() + PString(":") + PString(portNo), sender); } -void MessageFrame::ProcessAdviseSendAddress(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessAdviseSendAddress(const PStringArray &cmds, const PString & sender) { if (cmds.GetSize() < 2) { PTRACE(3, "failed to specify destination port & address"); @@ -639,17 +641,17 @@ return; } -void MessageFrame::ProcessDuration(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessDuration(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } -void MessageFrame::ProcessIdentify(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessIdentify(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } -void MessageFrame::ProcessDebug(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } @@ -662,7 +664,7 @@ } */ -void MessageFrame::ProcessTransferUdp(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessTransferUdp(const PStringArray &cmds, const PString & sender) { if (cmds.GetSize() < 2) { PTRACE(3, cmds[0] << " Failed - too few commands" << sender); @@ -728,12 +730,12 @@ } -void MessageFrame::ProcessQuitNow(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessQuitNow(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Command ") + cmds[0] + PString(" not handled"), sender); } -void MessageFrame::ProcessHelp(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessHelp(const PStringArray &cmds, const PString & sender) { PString reply; @@ -775,7 +777,7 @@ return false; } -void MessageFrame::ProcessSendDtmf(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessSendDtmf(const PStringArray &cmds, const PString & sender) { if (cmds.GetSize() < 2) { PTRACE(3, cmds[0] << " Failed - dtmf chars not supplied" << sender); @@ -787,13 +789,13 @@ } } -void MessageFrame::ProcessRequestNewId(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessRequestNewId(const PStringArray &cmds, const PString & sender) { PTRACE(1, cmds[0] <<" is not implmented"); } -void MessageFrame::ProcessSetReadFile(PStringArray &cmds, const PString & sender) +void MessageFrame::ProcessSetReadFile(const PStringArray &cmds, const PString & sender) { if (cmds.GetSize() != 2) { PTRACE(3, cmds[0] << " Failed - Read file not correctly specified" @@ -804,7 +806,7 @@ SetReadFile(cmds[1]); } -void MessageFrame::ProcessSetWriteFile(PStringArray &cmds, const PString & sender) +void MessageFrame::ProcessSetWriteFile(const PStringArray &cmds, const PString & sender) { if (cmds.GetSize() != 2) { PStringStream error; @@ -820,7 +822,7 @@ #ifdef PMEMORY_CHECK -void MessageFrame::ProcessMemoryDump(PStringArray &cmds, PString & sender) +void MessageFrame::ProcessMemoryDump(const PStringArray &cmds, const PString & sender) { PMemoryHeap::DumpObjectsSince(memoryState); Modified: sofaswitch/trunk/voip/comms.cxx ============================================================================== --- sofaswitch/trunk/voip/comms.cxx (original) +++ sofaswitch/trunk/voip/comms.cxx Sun Jul 27 00:47:16 2008 @@ -86,7 +86,7 @@ PTRACE(3, "END of comms communications for " << GetOurId()); } -void Comms::ProcessHangup(PStringArray &/*cmds*/, PString & /*sender*/) +void Comms::ProcessHangup(const PStringArray &/*cmds*/, const PString & /*sender*/) { PTRACE(3, "Process hangup message"); PWaitAndSignal m(opalCallLock); @@ -100,7 +100,7 @@ PTRACE(3, "Silently end all, which is \"ignored\""); } -void Comms::ProcessCallNode(PStringArray &cmds, PString & sender) +void Comms::ProcessCallNode(const PStringArray &cmds, const PString & sender) { { PWaitAndSignal m(opalCallLock); @@ -122,7 +122,7 @@ manager.StartCall(cmds[1], sender, GetOurId()); } -void Comms::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void Comms::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { opalCallLock.Wait(); if (myOpalCall == NULL) { @@ -137,7 +137,7 @@ } -void Comms::ProcessDuration(PStringArray &cmds, PString & sender) +void Comms::ProcessDuration(const PStringArray &cmds, const PString & sender) { opalCallLock.Wait(); if (myOpalCall == NULL) { @@ -152,17 +152,17 @@ SendThisMessageTo(duration, sender); } -void Comms::ProcessIdentify(PStringArray &cmds, PString & sender) +void Comms::ProcessIdentify(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(PString("Voip endpoint for one call ") + GetOurId(), sender); } -void Comms::ProcessDebug(PStringArray &cmds, PString & sender) +void Comms::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" debug on/off"), sender); } -void Comms::ProcessAnswer(PStringArray &cmds, PString & sender) +void Comms::ProcessAnswer(const PStringArray &cmds, const PString & sender) { { PWaitAndSignal m(opalCallLock); Modified: sofaswitch/trunk/voip/comms.h ============================================================================== --- sofaswitch/trunk/voip/comms.h (original) +++ sofaswitch/trunk/voip/comms.h Sun Jul 27 00:47:16 2008 @@ -114,29 +114,29 @@ virtual void OnTermination(); /**we have received a hangup message, so end the call */ - virtual void ProcessHangup(PStringArray &cmds, PString & sender); + virtual void ProcessHangup(const PStringArray &cmds, const PString & sender); /**we have received a Call other Node command, so do it and reply accordingly*/ - virtual void ProcessCallNode(PStringArray &cmds, PString & sender); + virtual void ProcessCallNode(const PStringArray &cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly*/ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**we have received a command queryig the current call duration , so extract information & answer */ - virtual void ProcessDuration(PStringArray &cmds, PString & sender); + virtual void ProcessDuration(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us how to answer to the incoming call, so we act as required and reply accordingly*/ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender); + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender); /**Send this dtmf string to the remote node. Returns true on success, false on failure. */ Modified: sofaswitch/trunk/voip/mymanager.cxx ============================================================================== --- sofaswitch/trunk/voip/mymanager.cxx (original) +++ sofaswitch/trunk/voip/mymanager.cxx Sun Jul 27 00:47:16 2008 @@ -635,7 +635,8 @@ return duration; } -void MyManager::RequestNewId(PString & requester) +void MyManager::RequestNewId(const PStringArray & cmds, + const PString & requester) { Comms *c; PINDEX attempt = 0; @@ -646,6 +647,7 @@ attempt++; } if (attempt >= 10) { + supervisor.SendThisMessageTo(cmds[0] + PString(" failed sorry."), requester); cerr << "not good - tried hard to make a running comms" << endl; cerr << "Give up now" << endl; return; @@ -653,7 +655,7 @@ c->SetRemoteController(requester); nodesMakingCalls.AddNewMessageFrame(c); - supervisor.SendThisMessageTo(PString("REQUESTNEWID ") + c->GetOurId(), requester); + supervisor.SendThisMessageTo(cmds[0] + PString(" ") + c->GetOurId(), requester); } bool MyManager::SendThisDtmf(const PString & token, const PString & thisDtmf) Modified: sofaswitch/trunk/voip/mymanager.h ============================================================================== --- sofaswitch/trunk/voip/mymanager.h (original) +++ sofaswitch/trunk/voip/mymanager.h Sun Jul 27 00:47:16 2008 @@ -208,7 +208,8 @@ /**Start the proces to get a new ID. The new ID is created by a separate thread, and the remote controller is advised when it is available */ - void RequestNewId(PString & requester); + void RequestNewId(const PStringArray & cmds, + const PString & requester); /**Check the different lists of Comms instances in this Manager (runningComms, deadComms, and nodesMakingCalls) and find the Modified: sofaswitch/trunk/voip/supervisor.cxx ============================================================================== --- sofaswitch/trunk/voip/supervisor.cxx (original) +++ sofaswitch/trunk/voip/supervisor.cxx Sun Jul 27 00:47:16 2008 @@ -83,17 +83,17 @@ #endif } -void Supervisor::ProcessAnswer(PStringArray &cmds, PString & sender) +void Supervisor::ProcessAnswer(const PStringArray &cmds, const PString & sender) { PAssertAlways("Supervisor should not attempt to answer a call"); } -void Supervisor::ProcessTransferUdp(PStringArray &cmds, PString & sender) +void Supervisor::ProcessTransferUdp(const PStringArray &cmds, const PString & sender) { PAssertAlways("Supervisor should not attempt to transfer a call"); } -void Supervisor::ProcessCallNode(PStringArray & cmds, PString & sender) +void Supervisor::ProcessCallNode(const PStringArray & cmds, const PString & sender) { PTRACE(3, "Supervisor:: we can start a call to " << sender); if (cmds.GetSize() < 2) { @@ -106,7 +106,7 @@ VoipProcess::Current().GetManager()->StartCall(cmds[1], sender, anyCommsId); } -void Supervisor::ProcessStatusQuery(PStringArray &cmds, PString & sender) +void Supervisor::ProcessStatusQuery(const PStringArray &cmds, const PString & sender) { PStringStream status; if (cmds.GetSize() >= 2) { @@ -119,17 +119,17 @@ } -void Supervisor::ProcessIdentify(PStringArray &cmds, PString & sender) +void Supervisor::ProcessIdentify(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" We are the opal supervisor"), sender); } -void Supervisor::ProcessDebug(PStringArray &cmds, PString & sender) +void Supervisor::ProcessDebug(const PStringArray &cmds, const PString & sender) { SendThisMessageTo(cmds[0] + PString(" debug on/off"), "", sender); } -void Supervisor::ProcessQuitNow(PStringArray &cmds, PString & sender) +void Supervisor::ProcessQuitNow(const PStringArray &cmds, const PString & sender) { SetRemoteController(sender); PTRACE(3, "Supervisor says::End everything now"); @@ -143,15 +143,16 @@ VoipProcess::Current().GetManager()->EndEverything(); } -void Supervisor::ProcessHangup(PStringArray &cmds, PString & sender) +void Supervisor::ProcessHangup(const PStringArray &cmds, const PString & sender) { PAssertAlways("Supervisor should not process a Hangup message"); } -void Supervisor::ProcessRequestNewId(PStringArray &/*cmds*/, PString & sender) +void Supervisor::ProcessRequestNewId(const PStringArray & cmds, + const PString & sender) { - VoipProcess::Current().GetManager()->RequestNewId(sender); + VoipProcess::Current().GetManager()->RequestNewId(cmds, sender); } bool Supervisor::ProcessDescendantCommands(const PStringArray & cmds, Modified: sofaswitch/trunk/voip/supervisor.h ============================================================================== --- sofaswitch/trunk/voip/supervisor.h (original) +++ sofaswitch/trunk/voip/supervisor.h Sun Jul 27 00:47:16 2008 @@ -81,36 +81,37 @@ virtual void OnTermination(); /**we have received a hangup message, so end the call */ - virtual void ProcessHangup(PStringArray &cmds, PString & sender); + virtual void ProcessHangup(const PStringArray &cmds, const PString & sender); /**we have received a Call other Node command, so do it and reply accordingly*/ - virtual void ProcessCallNode(PStringArray & cmds, PString & sender); + virtual void ProcessCallNode(const PStringArray & cmds, const PString & sender); /**This method is overridden as an error handler. The supervisor should never receive this message */ - void ProcessTransferUdp(PStringArray &cmds, PString & sender); + void ProcessTransferUdp(const PStringArray &cmds, const PString & sender); /**we have received a query status command, so do it and reply accordingly*/ - virtual void ProcessStatusQuery(PStringArray &cmds, PString & sender); + virtual void ProcessStatusQuery(const PStringArray &cmds, const PString & sender); /**we have received a command requesting that we identify ourselves so do it and reply accordingly*/ - virtual void ProcessIdentify(PStringArray &cmds, PString & sender); + virtual void ProcessIdentify(const PStringArray &cmds, const PString & sender); /**we have received a command which enables/disables debug information so install as required and reply accordingly*/ - virtual void ProcessDebug(PStringArray &cmds, PString & sender); + virtual void ProcessDebug(const PStringArray &cmds, const PString & sender); /**we have received a command advising us that we are to end now */ - virtual void ProcessQuitNow(PStringArray &cmds, PString & sender); + virtual void ProcessQuitNow(const PStringArray &cmds, const PString & sender); /**we have received a command asking us to provide the id of a new communications nodes, that will be controlled only by the remote node */ - virtual void ProcessRequestNewId(PStringArray &cmds, PString & sender); + virtual void ProcessRequestNewId(const PStringArray &cmds, + const PString & sender); /**Placed here - the child class has this method as pure virtual... */ - virtual void ProcessAnswer(PStringArray &cmds, PString & sender); + virtual void ProcessAnswer(const PStringArray &cmds, const PString & sender); /**Report to the sender the status of the lists in the iax portion of opal. */ virtual void ProcessIaxStatus(const PStringArray &cmds, const PString & sender);
participants (1)
-
SofaSWITCH SVN