sofaswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- 390 discussions
[Sofaswitch-svn] [commit] r433 - in sofaswitch/trunk: am mcu sofa/include/sofa sofa/src voip
by SofaSWITCH SVN 27 Jul '08
by SofaSWITCH SVN 27 Jul '08
27 Jul '08
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);
1
0
[Sofaswitch-svn] [commit] r432 - in sofaswitch/trunk: callflow/src sofa/include/sofa sofa/src voip
by SofaSWITCH SVN 25 Jul '08
by SofaSWITCH SVN 25 Jul '08
25 Jul '08
Author: derek
Date: Fri Jul 25 01:00:20 2008
New Revision: 432
Modified:
sofaswitch/trunk/callflow/src/callstartstop.cpp
sofaswitch/trunk/callflow/src/endcall.cpp
sofaswitch/trunk/callflow/src/transfermedia.cpp
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/counts.cxx
sofaswitch/trunk/voip/counts.h
sofaswitch/trunk/voip/jocall.cxx
sofaswitch/trunk/voip/mymanager.cxx
sofaswitch/trunk/voip/mymanager.h
sofaswitch/trunk/voip/supervisor.cxx
Log:
Lots of tidy ups to improve the efficiency of the voip subsystem.
Minor cleanups to callflow to make it more robust.
Modified: sofaswitch/trunk/callflow/src/callstartstop.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/callstartstop.cpp (original)
+++ sofaswitch/trunk/callflow/src/callstartstop.cpp Fri Jul 25 01:00:20 2008
@@ -64,6 +64,18 @@
file.AddLine(wxT(" try: "));
file.AddLine(wxT(" self.rhost = eval(self.data[a][\"worker node\"]) "));
file.AddLine(wxT(" except: "));
+ switch (kind) {
+ case MakeCall:
+ file.AddLine(wxT(" print \"Attempting to make a call \""));
+ break;
+ case EndCall:
+ file.AddLine(wxT(" print \"Attempting to end a call \""));
+ break;
+ case AcceptCall:
+ file.AddLine(wxT(" print \"Attempting to accept a call \" "));
+ break;
+ default:;
+ }
file.AddLine(wxT(" print \"The worker node string \", self.data[a][\"worker node\"], \" could not be evaluated as a Python string\" "));
file.AddLine(wxT(" self.rhost = \"\" "));
if (kind == MakeCall) {
Modified: sofaswitch/trunk/callflow/src/endcall.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/endcall.cpp (original)
+++ sofaswitch/trunk/callflow/src/endcall.cpp Fri Jul 25 01:00:20 2008
@@ -22,10 +22,6 @@
{
}
-
-
-
-
void DndShapeEndCall::Draw(wxDC & dc)
{
DndShapeCallStartStop::Draw(dc);
Modified: sofaswitch/trunk/callflow/src/transfermedia.cpp
==============================================================================
--- sofaswitch/trunk/callflow/src/transfermedia.cpp (original)
+++ sofaswitch/trunk/callflow/src/transfermedia.cpp Fri Jul 25 01:00:20 2008
@@ -69,24 +69,26 @@
bool DndShapeTransferMedia::WriteSystemCode(wxTextFile & file)
{
- file.AddLine(wxT(" def Transfer_Media(self, sTuple): "));
- file.AddLine(wxT(" a,b,c = sTuple "));
- file.AddLine(wxT(" self.tMedia = self.data[a][\"worker node\"] "));
- file.AddLine(wxT(" try: "));
- file.AddLine(wxT(" self.rhost = eval(self.tMedia) "));
- file.AddLine(wxT(" except: "));
- file.AddLine(wxT(" print \"The Worker node Python \", self.tMedia, \" could not be evaluated\" "));
- file.AddLine(wxT(" return self.data[a][\"Output\"] "));
-
- file.AddLine(wxT(" self.wNode = self.data[a][\"worker receiver\"] "));
- file.AddLine(wxT(" try: "));
- file.AddLine(wxT(" self.rhost += \":TRANSFERUDP \" + eval(self.wNode) + \"\\0\" "));
- file.AddLine(wxT(" except: "));
- file.AddLine(wxT(" print \"The node to transfer media to \", self.wNode, \" could not be evaluated\" "));
- file.AddLine(wxT(" return self.data[a][\"Output\"] "));
+ file.AddLine(wxT(" def Transfer_Media(self, sTuple): "));
+ file.AddLine(wxT(" a,b,c = sTuple "));
+ file.AddLine(wxT(" self.tMedia = self.data[a][\"worker node\"] "));
+ file.AddLine(wxT(" self.wNode = self.data[a][\"worker receiver\"] "));
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" self.rhost = eval(self.tMedia) "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"The transfer media node Python \", self.tMedia, \" could not be evaluated\""));
+ file.AddLine(wxT(" print \"Unsure on the validity of the string \", self.wNode, \" as yet\" "));
+ file.AddLine(wxT(" return self.data[a][\"Output\"] "));
+
+ file.AddLine(wxT(" try: "));
+ file.AddLine(wxT(" self.rhost += \":TRANSFERUDP \" + eval(self.wNode) + \"\\0\" "));
+ file.AddLine(wxT(" except: "));
+ file.AddLine(wxT(" print \"The node to transfer media to \", self.wNode, \" could not be evaluated\" "));
+ file.AddLine(wxT(" print \"However, python did evaluate \", self.tMedia, \" just fine\" "));
+ file.AddLine(wxT(" return self.data[a][\"Output\"] "));
- file.AddLine(wxT(" self.transport.write(self.rhost) "));
- file.AddLine(wxT(" return self.data[a][\"Output\"] "));
+ file.AddLine(wxT(" self.transport.write(self.rhost) "));
+ file.AddLine(wxT(" return self.data[a][\"Output\"] "));
file.AddLine(wxT(""));
return true;
Modified: sofaswitch/trunk/sofa/include/sofa/messages.h
==============================================================================
--- sofaswitch/trunk/sofa/include/sofa/messages.h (original)
+++ sofaswitch/trunk/sofa/include/sofa/messages.h Fri Jul 25 01:00:20 2008
@@ -368,12 +368,6 @@
#endif
private:
- /**Close the messages socket, and send a terminating message to
- the remote controller. Only this class can close this
- socket. This helps to ensure it is closed down at the end of
- all comms.*/
- void CloseMessagesSocket();
-
/**Keep a reference of the class responsible for creating new
unique IDs, which are derived from the supplied node Id..*/
LaunchNewId & lid;
Modified: sofaswitch/trunk/sofa/src/messages.cxx
==============================================================================
--- sofaswitch/trunk/sofa/src/messages.cxx (original)
+++ sofaswitch/trunk/sofa/src/messages.cxx Fri Jul 25 01:00:20 2008
@@ -145,14 +145,6 @@
SendThisMessageTo(PString("RECEIVEDDTMF ") + receivedDtmf, GetRemoteController());
}
-void MessageFrame::CloseMessagesSocket()
-{
- PTRACE(3, "Close messages socket for " << GetOurId());
-
- PThread::Sleep(100); //Let the message be sent, then close the socket.
- messagesSocket.Close();
-}
-
bool MessageFrame::WaitUntilInitialised()
{
PTRACE(3, "WaitForInitialised start");
@@ -188,7 +180,7 @@
{
keepGoing = false;
audioSocket.Close();
- CloseMessagesSocket();
+ messagesSocket.Close();
threadRunning.Signal();
goodConnection.Signal();
writeSourceId.Signal();
@@ -350,7 +342,7 @@
}
PTRACE(3, "End of Process Incoming Messages - thread has finished");
- CloseMessagesSocket();
+ messagesSocket.Close();
OnTermination();
return;
@@ -452,7 +444,7 @@
if (OkToHangup()) {
keepGoing = false;
ProcessHangup(cmds, sender);
- CloseMessagesSocket();
+ messagesSocket.Close();
} else {
SendThisMessageTo("This communications instance cannot hangup", sender);
PTRACE(2, "Hangup ignored, as we cannot hangup..");
@@ -519,7 +511,7 @@
if (OkToQuitNow()) {
keepGoing = false;
ProcessQuitNow(cmds, sender);
- CloseMessagesSocket();
+ messagesSocket.Close();
} else {
SendThisMessageTo("Insufficient Privilidgets to cause a shutdown", sender);
PTRACE(2, "Quitnow aborted, as insufficient priviledges");
Modified: sofaswitch/trunk/voip/comms.cxx
==============================================================================
--- sofaswitch/trunk/voip/comms.cxx (original)
+++ sofaswitch/trunk/voip/comms.cxx Fri Jul 25 01:00:20 2008
@@ -59,6 +59,7 @@
void Comms::OnOpalCallCleared()
{
PWaitAndSignal m(opalCallLock);
+ DecEstablished();
if (myOpalCall != NULL) {
myOpalCall->SafeDereference();
myOpalCall = NULL;
@@ -74,16 +75,10 @@
void Comms::SetMyOpalCallPtr(MyOpalCall *ptr)
{
- myOpalCall = ptr;
- ptr->SafeReference();
- opalCallToken = ptr->GetToken();
-}
-
-void Comms::StopAllCommunications()
-{
- PTRACE(5, "Comms StopAllComms Start " << GetOurId());
- Terminate();
- PTRACE(5, "Comms StopAllComms All done " << GetOurId());
+ IncEstablished();
+ myOpalCall = ptr;
+ ptr->SafeReference();
+ opalCallToken = ptr->GetToken();
}
void Comms::OnTermination()
@@ -105,12 +100,6 @@
PTRACE(3, "Silently end all, which is \"ignored\"");
}
-void Comms::CloseThisId()
-{
- audioSocket.Close();
- Terminate();
-}
-
void Comms::ProcessCallNode(PStringArray &cmds, PString & sender)
{
{
@@ -274,7 +263,7 @@
for(PINDEX i = 0; i < PAbstractList::GetSize(); i++) {
mf = (Comms *)PAbstractList::GetAt(i);
- new CommsConsumer(manager, mf);
+ new CommsConsumer(mf);
}
}
@@ -296,38 +285,26 @@
////////////////////////////////////////////////////////////////////////////////
-CommsConsumer::CommsConsumer(MyManager &_manager, Comms *m)
- :PThread(10000, AutoDeleteThread, LowPriority, "%X Comms delete"),
- manager(_manager),
+CommsConsumer::CommsConsumer(Comms *m)
+ :PThread(10000, AutoDeleteThread, NormalPriority, "%X Comms delete"),
comms(m)
{
PTRACE(2, "Create a Clear Comms Consumer to clear a comms instance " << m->GetOurId());
Resume();
}
-
-CommsConsumer::~CommsConsumer()
-{
- PTRACE(2, "Finish Clear Comms Consumer to clear a comms instance " << ourId);
-}
-
+
void CommsConsumer::Main()
{
if (comms == NULL)
return;
- comms->WaitForTermination();
+ comms->Terminate();
- ourId = comms->GetOurId();
- PTRACE(3, "START checking: look for " << ourId << " to appear in a manager list");
+ comms->WaitForTermination();
- Comms *c = manager.ClearCommsId(ourId);
- if (c != NULL) {
- PTRACE(3, "NOW delete comms instance " << ourId);
- PTRACE(3, "as we found it and have exclusive access to it");
- PTRACE(3, "and know that this thread has finished.");
- delete c;
- }
+ delete comms;
}
+
/* The comment below is magic for those who use emacs to edit this file. */
/* With the comment below, the tab key does auto indent to 2 spaces. */
Modified: sofaswitch/trunk/voip/comms.h
==============================================================================
--- sofaswitch/trunk/voip/comms.h (original)
+++ sofaswitch/trunk/voip/comms.h Fri Jul 25 01:00:20 2008
@@ -70,10 +70,6 @@
/** Close down the handling of incoming message, and break the link to the MyOpalCall class
*/
~Comms();
-
- /**Send a message to the remote controller that we are closing down now */
- virtual void StopAllCommunications();
-
/**Send a message to the remote controller saying that we are created (and
established in the Opal sense of a connection). The id of this node is
appended to the message.
@@ -101,10 +97,6 @@
by control commands */
PUDPSocket &GetAudioSocket();
- /**Close this id off. Basically, tell the remote end we are closing,
- and stop the comms on the tcp socket. */
- void CloseThisId();
-
/**Retrieve the opal call token that opal has assigned to the
corresponding OpalCall */
PString GetOpalCallToken() { return opalCallToken; }
@@ -221,23 +213,15 @@
/**Constructer - create this class, which is given the Comms
instance to destroy. This consumer class then does the rest */
- CommsConsumer(MyManager & _manager, Comms *destroyMe);
-
- /**Destructor */
- ~CommsConsumer();
-
+ CommsConsumer(Comms *destroyMe);
+
/**Where this thread runs to do the work */
void Main();
protected:
- /**Reference to the class that knows everything about everything */
- MyManager & manager;
/**The instance we have to delete */
Comms *comms;
-
- /**The id associated with the comms instance we ahve to delete */
- PString ourId;
};
/////////////////////////////////////////////////////////////////////////////
Modified: sofaswitch/trunk/voip/counts.cxx
==============================================================================
--- sofaswitch/trunk/voip/counts.cxx (original)
+++ sofaswitch/trunk/voip/counts.cxx Fri Jul 25 01:00:20 2008
@@ -37,6 +37,7 @@
/////////////////////////////////////////////////////////////////////////////
PAtomicInteger countComms;
+PAtomicInteger countEstablished;
PAtomicInteger countMyManager;
PAtomicInteger countMyOpalCall;
PAtomicInteger countOpalUdpSsConnection;
@@ -45,6 +46,7 @@
PAtomicInteger countUdpSoundChannel;
PAtomicInteger countDelComms;
+PAtomicInteger countDelEstablished;
PAtomicInteger countDelMyManager;
PAtomicInteger countDelMyOpalCall;
PAtomicInteger countDelOpalUdpSsConnection;
@@ -61,6 +63,15 @@
return msg;
}
+PString GetCountEstablished()
+{
+ PStringStream msg;
+ msg << ::setw(6) << PString(countEstablished)
+ << ::setw(6) << PString(countDelEstablished)
+ << ::setw(6) << PString(countEstablished - countDelEstablished) << ::setw(0);
+ return msg;
+}
+
PString GetCountMyManager()
{
PStringStream msg;
@@ -117,6 +128,7 @@
}
void DecComms() { ++countDelComms; }
+void DecEstablished() { ++countDelEstablished; }
void DecMyManager() { ++countDelMyManager; }
void DecMyOpalCall() { ++countDelMyOpalCall; }
void DecOpalUdpSsConnection() { ++countDelOpalUdpSsConnection; }
@@ -125,6 +137,7 @@
void DecUdpSoundChannel() { ++countDelUdpSoundChannel; }
void IncComms() { ++countComms; }
+void IncEstablished() { ++countEstablished; }
void IncMyManager() { ++countMyManager; }
void IncMyOpalCall() { ++countMyOpalCall; }
void IncOpalUdpSsConnection() { ++countOpalUdpSsConnection; }
Modified: sofaswitch/trunk/voip/counts.h
==============================================================================
--- sofaswitch/trunk/voip/counts.h (original)
+++ sofaswitch/trunk/voip/counts.h Fri Jul 25 01:00:20 2008
@@ -41,39 +41,96 @@
+/**Decrement the count on the Audio Delay instances established */
void DecAudioDelay();
+
+/**Increment the count on the Audio Delay instances established */
void IncAudioDelay();
+
+/**Report the count on the Audio Delay instances established */
PString GetCountAudioDelay();
+/**Decrement the count on SofaSwitch Communication instances established */
void DecComms();
+
+/**Increment the count on SofaSwitch Communication instances established */
void IncComms();
+
+/**Reportt the count on SofaSwitch Communication instances established */
PString GetCountComms();
+/**This is for debugging purposes, and may be used to keep track of
+ count of any particular variable - look for size of any list for
+ example. DECREMENT operation */
+void DecEstablished();
+
+/**This is for debugging purposes, and may be used to keep track of
+ count of any particular variable - look for size of any list for
+ example. INCREMENT operation */
+void IncEstablished();
+
+/**This is for debugging purposes, and may be used to keep track of
+ count of any particular variable - look for size of any list for
+ example. Report this variable. */
+PString GetCountEstablished();
+
+/**Decrement the count on SofaSwitch Manager instances established */
void DecMyManager();
+
+/**Increment the count on SofaSwitch Manager instances established */
void IncMyManager();
+
+/**Report the count on SofaSwitch Manager instances established */
PString GetCountMyManager();
+/**Decrement the count on SofaSwitch OpalCall instances established */
void DecMyOpalCall();
+
+/**Increment the count on SofaSwitch OpalCall instances established */
void IncMyOpalCall();
+
+/**Report the count on SofaSwitch OpalCall instances established */
PString GetCountMyOpalCall();
+/**Decrement the count on SofaSwitch Connection instances established */
void DecOpalUdpSsConnection();
+
+/**Increment the count on SofaSwitch Connection instances established */
void IncOpalUdpSsConnection();
+
+/**Report the count on SofaSwitch Connection instances established */
PString GetCountOpalUdpSsConnection();
+/**Decrement the count on SofaSwitch EndPoints established */
void DecOpalUdpSsEndPoint();
+
+/**Increment the count on SofaSwitch EndPoints established */
void IncOpalUdpSsEndPoint();
+
+/**Report the count on SofaSwitch EndPoints established */
PString GetCountOpalUdpSsEndPoint();
+/**Decrement the count on Supervisors established */
void DecSupervisor();
+
+/**Increment the count on Supervisors established */
void IncSupervisor();
+
+/**Report the count on Supervisors established */
PString GetCountSupervisor();
+/**Decrement the count on sound channel established */
void DecUdpSoundChannel();
+
+/**Increment the count on sound channel established */
void IncUdpSoundChannel();
+
+/**Report the count on sound channel established */
PString GetCountUdpSoundChannel();
+
+
#endif // _COUNTS_H
Modified: sofaswitch/trunk/voip/jocall.cxx
==============================================================================
--- sofaswitch/trunk/voip/jocall.cxx (original)
+++ sofaswitch/trunk/voip/jocall.cxx Fri Jul 25 01:00:20 2008
@@ -75,13 +75,8 @@
MyOpalCall::~MyOpalCall()
{
PTRACE(3, "Destructor for Opal Call " << GetToken() << " and " << comms.GetOurId());
- comms.StopAllCommunications();
-/* The comms instance must not self delete on completion. We stop the comms
- instance, and then we delete it (as we are finished with it) */
-
- comms.WaitForTermination();
- manager.AppendFinishedComms(commsPtr);
+ new CommsConsumer(commsPtr);
PTRACE(3, "MyOpalCall\t" << *this << " destroyed dead and gone");
DecMyOpalCall();
}
@@ -89,35 +84,14 @@
bool MyOpalCall::OnSetUp(OpalConnection & connection)
{
PTRACE(3, "Call\tOnSetUp " << connection);
-
- bool ok = false;
-
- if (!LockReadWrite()) {
- PTRACE(3, "failed to lock the read write");
- return false;
- }
-
- PTRACE(3, "ConnectionsActive has a size of "
- << connectionsActive.GetSize());
-
- UnlockReadWrite();
-
- PINDEX i = 1;
- for (PSafePtr<OpalConnection> conn(connectionsActive, PSafeReadOnly); conn != NULL; ++conn, i++) {
- PTRACE(3, "connection " << i << " is " << (*conn));
- }
for (PSafePtr<OpalConnection> conn(connectionsActive, PSafeReadOnly); conn != NULL; ++conn) {
PTRACE(3, "TRY " << (*conn));
if (conn != &connection) {
PTRACE(3, "Now do a setup");
- if (conn->SetUpConnection()) {
- PTRACE(3, "set up the connection ok ");
- ok = true;
- }
+ conn->SetUpConnection();
}
}
- PTRACE(2, "finished onsetup of connection/call and it gave " << 1);
return true;
}
@@ -214,7 +188,7 @@
void MyOpalCall::CloseThisId()
{
- comms.CloseThisId();
+ comms.Terminate();
}
PUDPSocket & MyOpalCall::GetAudioSocket()
Modified: sofaswitch/trunk/voip/mymanager.cxx
==============================================================================
--- sofaswitch/trunk/voip/mymanager.cxx (original)
+++ sofaswitch/trunk/voip/mymanager.cxx Fri Jul 25 01:00:20 2008
@@ -107,7 +107,6 @@
supervisor.Resume();
nodesMakingCalls.Initialise();
- nodesFinishedCalls.Initialise();
runningComms.SetPreAllocatedSize(10);
runningComms.Initialise();
@@ -463,9 +462,9 @@
void MyManager::AcceptThisCall(const PString & uniqueCallId, bool doAccept)
{
PTRACE(3, "Accept this call if we can find it " << uniqueCallId);
- PSafePtr<OpalCall> oCall = FindCallWithLock(uniqueCallId);
+ PSafePtr<OpalCall> oCall = FindCallWithLock(uniqueCallId, PSafeReadOnly);
if (oCall == NULL) {
- PTRACE(3, "Failed to accept call with a token of " << uniqueCallId);
+ PTRACE(3, "Failed to accept call with a token of ");
return;
}
@@ -478,7 +477,7 @@
PString MyManager::GetStatusInfo(const PString & token)
{
- PSafePtr<OpalCall> call = FindCallWithLock(token);
+ PSafePtr<OpalCall> call = FindCallWithLock(token, PSafeReadOnly);
if (call == NULL) {
return "Status unavailable as not in a call";
}
@@ -543,6 +542,8 @@
status << "--------------" << endl;
status << " Comms count is "
<< GetCountComms() << endl;
+ status << " Established count is "
+ << GetCountEstablished() << endl;
status << " MyManager count is "
<< GetCountMyManager() << endl;
status << " MyOpalCall count is "
@@ -619,25 +620,12 @@
return c;
}
- c = (Comms *)nodesFinishedCalls.GetMessageFrameOn(memberId);
- if (c != NULL) {
- PTRACE(3, "Clear comms Id on " << memberId << " for comms instances finished in a call");
- return c;
- }
-
return NULL;
}
-void MyManager::AppendFinishedComms(Comms *commsPtr)
-{
- PTRACE(3, "Manager\tThis comms instance has finished a call, and is about to DIE" << commsPtr->GetOurId());
- nodesFinishedCalls.AddNewMessageFrame(commsPtr);
- new CommsConsumer(*this, commsPtr);
-}
-
PString MyManager::GetDurationInfo(const PString & token)
{
- PSafePtr<OpalCall> call = FindCallWithLock(token);
+ PSafePtr<OpalCall> call = FindCallWithLock(token, PSafeReadOnly);
if (call == NULL) {
return "Duration unavailable as not in a call";
}
@@ -671,7 +659,7 @@
bool MyManager::SendThisDtmf(const PString & token, const PString & thisDtmf)
{
PTRACE(3, "MyManager\tSend this dtmf " << thisDtmf << " to call " << token);
- OpalCall *oCall = FindCallWithLock(token);
+ OpalCall *oCall = FindCallWithLock(token, PSafeReadOnly);
if (oCall == NULL) {
PTRACE(3, "MyManager\tSend this dtmf " << thisDtmf << " to call " << token << " FAILED - call not found");
return false;
@@ -981,7 +969,7 @@
/*
* Local Variables:
* mode:c
- * c-basic-offset:4
+ * c-basic-offset:2
* End:
*/
Modified: sofaswitch/trunk/voip/mymanager.h
==============================================================================
--- sofaswitch/trunk/voip/mymanager.h (original)
+++ sofaswitch/trunk/voip/mymanager.h Fri Jul 25 01:00:20 2008
@@ -256,14 +256,9 @@
deleted */
MessageFrameListPending nodesMakingCalls;
- /**A list of the nodes who have completed calls they are in. Frames will
- be deleted by the CommsConsumer class, which will fish the node out of
- this list and delete it. */
- MessageFrameList nodesFinishedCalls;
-
-
- /**A list of Comms instances that are known to have died. Comms instances will be
- removed from this list by the CommsConsumer class.*/
+ /**A list of Comms instances that are known to have died. Comms
+ instances will be removed from this list by the CommsConsumer
+ class.*/
MessageFrameList deadComms;
/**The sound system endpoint that we use to control talk to the
Modified: sofaswitch/trunk/voip/supervisor.cxx
==============================================================================
--- sofaswitch/trunk/voip/supervisor.cxx (original)
+++ sofaswitch/trunk/voip/supervisor.cxx Fri Jul 25 01:00:20 2008
@@ -209,11 +209,10 @@
PString specialAnswer;
specialPacketHandler->ReportLists(specialAnswer);
- answer << "specialHand " << specialAnswer << "\n";
- {
- PWaitAndSignal m(mutexTokenTable);
- answer << "token size " << tokenTable.GetSize() << "\n";
- }
+ answer << "specialHand " << specialAnswer << "\n";
+ mutexTokenTable.StartRead();
+ answer << "token size " << tokenTable.GetSize() << "\n";
+ mutexTokenTable.EndRead();
{
PWaitAndSignal m(regProcessorsMutex);
answer << "Reg Processors " << regProcessors.GetSize() << "\n";
1
0
Author: derek
Date: Mon Jul 21 23:13:27 2008
New Revision: 431
Modified:
sofaswitch/trunk/am/audio.cxx
sofaswitch/trunk/am/comms.cxx
Log:
Tidy up operation so it operates correctly when just the write file is specified.
Improve reporting on the status command to accurate describe what is happening.
Modified: sofaswitch/trunk/am/audio.cxx
==============================================================================
--- sofaswitch/trunk/am/audio.cxx (original)
+++ sofaswitch/trunk/am/audio.cxx Mon Jul 21 23:13:27 2008
@@ -70,6 +70,7 @@
EnactFileChange();
if (!audioFile.IsOpen()) {
+ PTRACE(3, "AudioRead\tNo action - source file is not available");
doThisRead = false;
}
@@ -80,7 +81,7 @@
PTRACE(1, "Send end of file as we hav read the end of this file." << fileName);
comms->SendEndOfFile();
sentEndOfFile = true;
- PTRACE(4, "End of this file, currently at " << audioFile.GetPosition() <<
+ PTRACE(4, "AudioRead\tEnd of this file, currently at " << audioFile.GetPosition() <<
" index, of a total of " <<audioFile.GetDataLength() << " bytes");
}
}
@@ -91,10 +92,10 @@
if (audioFile.GetErrorCode() != PChannel::NoError) {
doThisRead = false;
if (!sentEndOfFile) {
- PTRACE(1, "Send end of file as we had an error in read, " << audioFile.GetErrorText());
+ PTRACE(1, "AudioRead\tSend end of file as we had an error in read, " << audioFile.GetErrorText());
comms->SendEndOfFile();
sentEndOfFile = true;
- PTRACE(3, "AudioRead\t failed with error text " << audioFile.GetErrorText());
+ PTRACE(3, "AudioRead\tfailed with error text " << audioFile.GetErrorText());
}
}
lastReadCount = audioFile.GetLastReadCount();
@@ -102,7 +103,7 @@
}
if (doThisRead) {
- PTRACE(3, dirString << "\tGrabbed " << lastReadCount << " bytes from the file " << fileName);
+ PTRACE(3, dirString << "AudioRead\tGrabbed " << lastReadCount << " bytes from the file " << fileName);
delayTime = data.GetSize()/16;
countPackets++;
socket->Write(data.GetPointer(), data.GetSize());
@@ -111,7 +112,7 @@
}
}
- PTRACE(3, "Delay " << delayTime << " ms after the read");
+ PTRACE(3, "AudioRead\tDelay " << delayTime << " ms after the read");
delay.Delay(delayTime);
}
@@ -164,15 +165,16 @@
EnactFileChange();
if (!audioFile.IsOpen()) {
+ PTRACE(3, "AudioWrite\tNo action - destination file is closed");
continue;
}
audioFile.Write(data.GetPointer(), lastReadCount);
countPackets++;
- if (audioFile.GetErrorCode() != PChannel::NoError) {
- PTRACE(3, "AudioWrite\t failed with error text " << audioFile.GetErrorText());
+ if (audioFile.GetErrorCode() == PChannel::NoError) {
+ PTRACE(3, "AudioWrite\tSent " << lastReadCount << " bytes to the file " << fileName);
} else {
- PTRACE(3, "AudioWrite\tSent " << data.GetSize() << " bytes to the file " << fileName);
+ PTRACE(3, "AudioWrite\t failed with error text " << audioFile.GetErrorText());
}
}
}
Modified: sofaswitch/trunk/am/comms.cxx
==============================================================================
--- sofaswitch/trunk/am/comms.cxx (original)
+++ sofaswitch/trunk/am/comms.cxx Mon Jul 21 23:13:27 2008
@@ -167,9 +167,12 @@
{
PTRACE(3, "Coms::ProcessStatusQuery");
- if (!audioReadThread.IsInitialised()) {
- SendThisMessageTo("not yet in a call", sender);
- return;
+ if ((!audioReadThread.IsInitialised()) && (!audioWriteThread.IsInitialised())) {
+ PStringStream answer;
+ answer << "\n Currently linked to " << GetMediaPartner();
+ answer << "\n No audio file specified - read and/or write cannot happen.\n";
+ SendThisMessageTo(answer, sender);
+ return;
}
PString status = GetStatusInfo();
1
0
Author: derek
Date: Sun Jul 20 22:45:12 2008
New Revision: 430
Modified:
sofaswitch/trunk/voip/mymanager.cxx
sofaswitch/trunk/voip/mymanager.h
sofaswitch/trunk/voip/supervisor.cxx
sofaswitch/trunk/voip/supervisor.h
Log:
Add additional command of (iaxstatus and iaxstatus full)
This command reports on the usage in OPAL's iax lists.
Modified: sofaswitch/trunk/voip/mymanager.cxx
==============================================================================
--- sofaswitch/trunk/voip/mymanager.cxx (original)
+++ sofaswitch/trunk/voip/mymanager.cxx Sun Jul 20 22:45:12 2008
@@ -330,7 +330,7 @@
// Create IAX2 protocol handler
if (!args.HasOption("no-iax2")) {
- iax2EP = new IAX2EndPoint(*this);
+ iax2EP = new ReportingIAX2EndPoint(*this);
if (args.HasOption('p'))
iax2EP->SetPassword(args.GetOptionString('p'));
Modified: sofaswitch/trunk/voip/mymanager.h
==============================================================================
--- sofaswitch/trunk/voip/mymanager.h (original)
+++ sofaswitch/trunk/voip/mymanager.h Sun Jul 20 22:45:12 2008
@@ -229,6 +229,16 @@
comms instances in a call */
PSortedStringList GetCurrentNames();
+
+ /**Return the pointer to the iax2 endpoint. This is used for
+ retrieving stats, and is dangerous to be used for other
+ things. */
+#if OPAL_IAX2
+ void *GetIax2Ep() { return (void *)iax2EP; }
+#else
+ void *GetIax2Ep() { return NULL; }
+#endif
+
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 Sun Jul 20 22:45:12 2008
@@ -29,6 +29,7 @@
*/
#include <ptlib.h>
+#include <iax2/receiver.h>
#ifdef __GNUC__
#pragma implementation "supervisor.h"
@@ -42,6 +43,7 @@
#include "supervisor.h"
+
#define new PNEW
////////////////////////////////////////////////////////////////////////////////
@@ -52,6 +54,8 @@
{
IncSupervisor();
PTRACE(3, "Create a supervisor ");
+
+ extraAvailableCommands += PString(/* 0 */ "IAXSTATUS");
}
Supervisor::~Supervisor()
@@ -150,6 +154,74 @@
VoipProcess::Current().GetManager()->RequestNewId(sender);
}
+bool Supervisor::ProcessDescendantCommands(const PStringArray & cmds,
+ const PString & sender)
+{
+ if (extraAvailableCommands[0] *= cmds[0]) {
+ PTRACE(4, "Process iax status");
+ ProcessIaxStatus(cmds, sender);
+ return true;
+ }
+
+ return false;
+}
+
+void Supervisor::ProcessIaxStatus(const PStringArray & cmds,
+ const PString & sender)
+{
+ MyManager *opal = VoipProcess::Current().GetManager();
+ PStringStream answer;
+
+ void *iax2Ep = opal->GetIax2Ep();
+ if (iax2Ep == NULL) {
+ answer << PString("FAILED as this SofaSwitch node does ");
+ answer << PString("not support iax. Sorry");
+ }
+
+#if OPAL_IAX2
+ ReportingIAX2EndPoint *r = (ReportingIAX2EndPoint *)iax2Ep;
+ bool fullReport = false;
+ if (cmds.GetSize() >= 2) {
+ fullReport = cmds[1] *= PString("full");
+ }
+ answer << PString("\n") << r->GetListSizes(fullReport);
+#endif
+
+ SendThisMessageTo(answer, sender);
+ return;
+}
+/////////////////////////////////////////////////////////////////////////////
+
+ReportingIAX2EndPoint::ReportingIAX2EndPoint(OpalManager & manager)
+ : IAX2EndPoint(manager)
+{
+
+}
+
+PString ReportingIAX2EndPoint::GetListSizes(bool getFullReport)
+{
+ PStringStream answer;
+ PString transmitterAnswer;
+ ReportTransmitterLists(transmitterAnswer, getFullReport);
+ answer << "Transmitter " << transmitterAnswer;
+ answer << "Receiver " << receiver->GetSize() << "\n";
+ answer << "RegProcessor" << regProcessors.GetSize() << "\n";
+
+ PString specialAnswer;
+ specialPacketHandler->ReportLists(specialAnswer);
+ answer << "specialHand " << specialAnswer << "\n";
+ {
+ PWaitAndSignal m(mutexTokenTable);
+ answer << "token size " << tokenTable.GetSize() << "\n";
+ }
+ {
+ PWaitAndSignal m(regProcessorsMutex);
+ answer << "Reg Processors " << regProcessors.GetSize() << "\n";
+ }
+
+ return answer;
+}
+
/* The comment below is magic for those who use emacs to edit this file. */
/* With the comment below, the tab key does auto indent to 2 spaces. */
Modified: sofaswitch/trunk/voip/supervisor.h
==============================================================================
--- sofaswitch/trunk/voip/supervisor.h (original)
+++ sofaswitch/trunk/voip/supervisor.h Sun Jul 20 22:45:12 2008
@@ -36,6 +36,7 @@
#include <ptlib.h>
#endif
+#include <iax2/iax2ep.h>
#include <sofa/messages.h>
#ifdef P_USE_PRAGMA
@@ -62,6 +63,17 @@
things like memory leak checkpoints */
virtual void OnRunning();
+ /**The voip supervisor can do extra commands that the generic message handler
+ cannot process. This method catches these extra command handling.
+
+ @return true if the voip supervisor did manage to decode the
+ commands. The default return is false; */
+ virtual bool ProcessDescendantCommands(const PStringArray & /*cmds*/,
+ const PString & /*sender*/);
+
+ /**Report here the extra commands the voip supervisor can process */
+ virtual PStringArray GetDescendantCommands() { return extraAvailableCommands; }
+
protected:
/**The supervisor has completed. This method is called when this
supervisor instance terminates. Since there is only one
@@ -100,6 +112,9 @@
/**Placed here - the child class has this method as pure virtual... */
virtual void ProcessAnswer(PStringArray &cmds, 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);
+
/**Some MessageFrame instances do not have the permission to quit
now. This virtual method determines if this instance is permitted to
exit the program. This is the supervisor, so we can cause a shutdown. */
@@ -109,6 +124,8 @@
no message to the remote node - just end end end. */
virtual void SilentlyEndAll();
+ /**The list of extra commands we can handle in the voip supervisor */
+ PStringArray extraAvailableCommands;
//////////////////////////////////////////////
private:
@@ -120,6 +137,25 @@
// CommsProvider availableComms;
};
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
+
+/**the purpose of this class is to access the members of the iax2ep for reporting on size */
+
+class ReportingIAX2EndPoint : public IAX2EndPoint
+{
+ PCLASSINFO(ReportingIAX2EndPoint, IAX2EndPoint);
+
+ public:
+ /**constructor, which just calls the descendant */
+ ReportingIAX2EndPoint(OpalManager & manager);
+
+ /**Get a string which details the size of the internal lists */
+ PString GetListSizes(bool getFullReport = false);
+};
+
+
+
#endif // _SUPERVISOR_H
1
0
Author: derek
Date: Sun Jul 20 22:43:21 2008
New Revision: 429
Modified:
sofaswitch/trunk/server/main.h
Log:
Tidy up formatting of doxygen comment.
Modified: sofaswitch/trunk/server/main.h
==============================================================================
--- sofaswitch/trunk/server/main.h (original)
+++ sofaswitch/trunk/server/main.h Sun Jul 20 22:43:21 2008
@@ -365,8 +365,9 @@
} connectionsActive;
#ifdef DOC_PLUS_PLUS
- /**This does the work of deleting all active connections. Using a thread to do the work
- saves a deadlock from an active connection trying to enact a close down. */
+ /**This does the work of deleting all active connections. Using a
+ thread to do the work saves a deadlock from an active connection
+ trying to enact a close down. */
virtual void DoQuitNow(PThread &, INT);
#else
PDECLARE_NOTIFIER(PThread, Manager, DoQuitNow);
1
0
21 Jul '08
Author: derek
Date: Sun Jul 20 22:42:45 2008
New Revision: 428
Modified:
sofaswitch/trunk/callflow/tests/forloop.src
Log:
Modify example forloop for clarity.
Modified: sofaswitch/trunk/callflow/tests/forloop.src
==============================================================================
--- sofaswitch/trunk/callflow/tests/forloop.src (original)
+++ sofaswitch/trunk/callflow/tests/forloop.src Sun Jul 20 22:42:45 2008
@@ -1 +1 @@
-4<B>301<B>152<B> extra <special>Tool Tip<ms>End For Loop<ms><special> <B><Shape>10<B>316<B>98<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "loop index is ", self.i<ms><special> <B><Shape>20<B>322<B>199<B> extra <special>Tool Tip<ms>Death<ms><special> <B><Shape>9<B>299<B>87<B>299,87,301,177<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>1<B>306<B>11<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>3<B>299<B>62<B> extra <special>Tool Tip<ms>Start For<ms><special>Initialise (Python code)<ms>self.i = 0<ms><special>Test for Termination (Python code)<ms>self.i < 10<ms><special>Increment (Python code)<ms>self.i+=1<ms><special> <B><Shape>
+9<B>299<B>87<B>299,87,301,177<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>1<B>306<B>11<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>3<B>299<B>62<B> extra <special>Tool Tip<ms>Start For<ms><special>Initialise (Python code)<ms>self.i = 0<ms><special>Test for Termination (Python code)<ms>self.i < 10<ms><special>Increment (Python code)<ms>self.i=self.i+1<ms><special> <B><Shape>4<B>301<B>152<B> extra <special>Tool Tip<ms>End For Loop<ms><special> <B><Shape>10<B>316<B>98<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "loop index is ", self.i<ms><special> <B><Shape>20<B>322<B>199<B> extra <special>Tool Tip<ms>Death<ms><special> <B><Shape>
1
0
[Sofaswitch-svn] [commit] r427 - in sofaswitch/trunk/sofa: include/sofa src
by SofaSWITCH SVN 21 Jul '08
by SofaSWITCH SVN 21 Jul '08
21 Jul '08
Author: derek
Date: Sun Jul 20 22:42:15 2008
New Revision: 427
Modified:
sofaswitch/trunk/sofa/include/sofa/messages.h
sofaswitch/trunk/sofa/src/messages.cxx
Log:
Tidy up formatting.
Add new methods so descendant class can process additional commands.
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 20 22:42:15 2008
@@ -63,6 +63,9 @@
/**Destructor, to close of any threads etc */
virtual ~MessageFrame();
+ /**Report what this comms class things about the status of this instance */
+ PString GetStatusInfo();
+
/**Wait until the messaging subsystem reports it is
initialised. Wait no more than 1 second. If not initialised,
return false. return true immediately on discovering we are
@@ -132,6 +135,20 @@
finished, and that this class is operational and running */
virtual void OnRunning() { };
+ /**Make available the processing of commands to descendant
+ classes. So that (for example) the voip supervisor can process
+ voip related commands
+
+ @return true if the descendant class did manage to decode the
+ commands. The default return is false; */
+ virtual bool ProcessDescendantCommands(const PStringArray & /*cmds*/,
+ const PString & /*sender*/)
+ { return false; }
+
+ /**Find out what commands the descendant class can process. This
+ command is used to process the help command */
+ virtual PStringArray GetDescendantCommands();
+
protected:
/**Called when this thread finishes. An application would call
@@ -150,7 +167,8 @@
/**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(PString & message,
+ PString & sender);
/**we have received a hangup message, so end the call */
virtual void ProcessHangup(PStringArray &cmds, PString & sender);
Modified: sofaswitch/trunk/sofa/src/messages.cxx
==============================================================================
--- sofaswitch/trunk/sofa/src/messages.cxx (original)
+++ sofaswitch/trunk/sofa/src/messages.cxx Sun Jul 20 22:42:15 2008
@@ -195,6 +195,19 @@
PTRACE(4, "Finish Terminate the message frame for " << GetOurId());
}
+PString MessageFrame::GetStatusInfo()
+{
+ PStringStream answer;
+ answer << "UDP audio socket is " << (audioSocket.IsOpen() ? "Open " : "Closed") << endl
+ << "TCP connection thread is " << (IsTerminated() ? "Stopped " : "Running") << endl
+ << "TCP command socket is " << (messagesSocket.IsOpen() ? "Open " : "Closed") << endl
+ << "Received last command from " << lastSender << endl
+ << "KeepGoing flag is " << (keepGoing ? "true " : "false") << endl
+ << "Media partner is " << mediaPartner << endl
+ << "Remote Controller is " << remoteController << endl;
+ return answer;
+}
+
void MessageFrame::Initialise()
{
SetThreadName(PString("Messages.") + ourId);
@@ -373,7 +386,7 @@
}
PString src = res.Left(l);
PString msg = res.Mid(l + 1);
- ProcessMessage(msg,src);
+ ProcessMessage(msg, src);
}
}
@@ -428,8 +441,10 @@
writeMessageLock.Signal();
}
-void MessageFrame::ProcessMessage(PString message, PString sender)
+void MessageFrame::ProcessMessage(PString & message,
+ PString & sender)
{
+ lastSender = sender;
PStringArray cmds = message.Tokenise(" ", false);
if (cmds[0] *= availableCommands[0]) {
@@ -561,7 +576,8 @@
return;
}
#endif
- PTRACE(3, PString("The command ") + cmds[0] + " was not understood");
+ if (ProcessDescendantCommands(cmds, sender) == false)
+ PTRACE(3, PString("The command ") + cmds[0] + " was not understood");
}
void MessageFrame::ProcessHangup(PStringArray &cmds, PString & sender)
@@ -728,11 +744,23 @@
void MessageFrame::ProcessHelp(PStringArray &cmds, PString & sender)
{
PString reply;
+
for (PINDEX i = 0; i < availableCommands.GetSize(); i++)
reply += availableCommands[i] + PString("\n");
+
+ PStringArray extraCommands = GetDescendantCommands();
+ for (PINDEX i = 0; i < extraCommands.GetSize(); i++)
+ reply += extraCommands[i] + PString("\n");
+
SendThisMessageTo(reply, sender);
}
+PStringArray MessageFrame::GetDescendantCommands()
+{
+ PStringArray emptyAnswer;
+ return emptyAnswer;
+}
+
bool MessageFrame::GetLocalAddress(PIPSocket::Address &address, PINDEX &portNo)
{
PIPSocket::InterfaceTable table;
1
0
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);
}
1
0
Author: derek
Date: Wed Jul 2 23:52:27 2008
New Revision: 425
Modified:
sofaswitch/trunk/sofa/src/messages.cxx
Log:
Tidy up locks in creation of identities.
Now, we correctly set them, so there is no deadlock on faulty initialisation.
Modified: sofaswitch/trunk/sofa/src/messages.cxx
==============================================================================
--- sofaswitch/trunk/sofa/src/messages.cxx (original)
+++ sofaswitch/trunk/sofa/src/messages.cxx Wed Jul 2 23:52:27 2008
@@ -220,6 +220,7 @@
if (!keepGoing) {
PTRACE(4, "initialize end - keepgoing is false ");
+ goodConnection.Signal();
return;
}
@@ -234,49 +235,50 @@
PTRACE(5, "ok - we have a good connection");
goodConnection.Signal();
+
if (!messagesSocket.SetOption(TCP_NODELAY, 1, IPPROTO_TCP)) {
PTRACE(1, "SetOption(TCP_NODELAY) failed: " << messagesSocket.GetErrorText());
- if (!keepGoing) {
- PTRACE(4, "initialize end TCP_NODELAY- keepgoing is false");
- return;
- }
+ keepGoing = false;
+ PTRACE(4, "initialize end TCP_NODELAY- keepgoing is false");
+ writeSourceId.Signal();
+ return;
}
if (!messagesSocket.SetOption(SO_KEEPALIVE, 1)) {
PTRACE(3, "SetOption(keepalive) failed: " << messagesSocket.GetErrorText());
- if (!keepGoing) {
- PTRACE(3, "initialize end SO_KEEPALIVE- keepgoing is false");
- return;
- }
+ keepGoing = false;
+ PTRACE(3, "initialize end SO_KEEPALIVE- keepgoing is false");
+ writeSourceId.Signal();
+ return;
}
#ifdef TCP_KEEPIDLE
if (!messagesSocket.SetOption(TCP_KEEPIDLE, 10, IPPROTO_TCP)) {
PTRACE(1, "SetOption(TCP_KEEPIDLE 2) failed: " << messagesSocket.GetErrorText());
- if (!keepGoing) {
- PTRACE(3, "initialize end TCP_KEEPIDLE 2- keepgoing is false");
- return;
- }
+ keepGoing = false;
+ PTRACE(3, "initialize end TCP_KEEPIDLE 2- keepgoing is false");
+ writeSourceId.Signal();
+ return;
}
#endif
#ifdef TCP_KEEPCNT
if (!messagesSocket.SetOption(TCP_KEEPCNT, 2, IPPROTO_TCP)) {
PTRACE(1, "SetOption(TCP_KEEPCNT 2) failed: " << messagesSocket.GetErrorText());
- if (!keepGoing) {
- PTRACE(3, "initialize TCP_KEEPCNT 2 end - keepgoing is false");
- return;
- }
- }
+ keepGoing = false;
+ PTRACE(3, "initialize TCP_KEEPCNT 2 end - keepgoing is false");
+ writeSourceId.Signal();
+ return;
+ }
#endif
#ifdef TCP_KEEPINTVL
if (!messagesSocket.SetOption(TCP_KEEPINTVL, 10, IPPROTO_TCP)) {
PTRACE(1, "SetOption(TCP_KEEPINTVL 2) failed: " << messagesSocket.GetErrorText());
- if (!keepGoing) {
- PTRACE(3, "initialize end TCP_KEEPINTVL 2- keepgoing is false");
- return;
- }
+ keepGoing = false;
+ PTRACE(3, "initialize end TCP_KEEPINTVL 2- keepgoing is false");
+ writeSourceId.Signal();
+ return;
}
#endif
1
0
Author: derek
Date: Wed Jul 2 23:45:34 2008
New Revision: 424
Modified:
sofaswitch/trunk/server/client.py
Log:
Go back to no up arrow - it breaks the shell...
Modified: sofaswitch/trunk/server/client.py
==============================================================================
--- sofaswitch/trunk/server/client.py (original)
+++ sofaswitch/trunk/server/client.py Wed Jul 2 23:45:34 2008
@@ -6,7 +6,7 @@
# See the description in server.py on how you use this program.
#
-import readline, socket, os, sys, thread
+import socket, os, sys, thread
if len(sys.argv) < 3:
print "Syntax: client.py myId destination_host"
@@ -35,7 +35,7 @@
thread.start_new(report_incoming,())
while True:
- value = raw_input("> ")
+ value = sys.stdin.readline()
value = value.strip()
if value == 'end':
sys.exit()
1
0