Module: sems
Branch: master
Commit: b6787ae6f74f6ce314f2472881371b4cf5ebc8b4
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=b6787ae6f74f6ce314f2472881371b4cf5ebc8b4

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Mon Apr 23 14:38:31 2012 +0200

callgen: add ncalls_per_sec option, use more real current call number

---

 apps/examples/call_gen/CallGen.cpp    |   20 +++++++++++++++-----
 apps/examples/call_gen/CallGen.h      |    2 +-
 apps/examples/call_gen/Readme.callgen |    2 ++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/apps/examples/call_gen/CallGen.cpp 
b/apps/examples/call_gen/CallGen.cpp
index 73e38f7..ebc114d 100644
--- a/apps/examples/call_gen/CallGen.cpp
+++ b/apps/examples/call_gen/CallGen.cpp
@@ -298,14 +298,25 @@ void CallGenFactory::scheduleCalls(const AmArg& args, 
AmArg& ret) {
   int    ncalls           = args.get(cnt++).asInt();
   int    wait_time_base   = args.get(cnt++).asInt();
   int    wait_time_rand   = args.get(cnt++).asInt();
+  int    ncalls_per_sec   = 1;
+  if (args.size()>8)
+    ncalls_per_sec = args[8].asInt();
+
   DBG("scheduling %d calls...\n", ncalls);
   
   time_t now;
   time(&now);
   actions_mut.lock();
-  for (int i=0;i<ncalls;i++) {
-    actions.insert(std::make_pair(now, args));
-    
+  int i=0;
+
+  while (i<ncalls) {
+    for (int j=0;j<ncalls_per_sec;j++) {
+      actions.insert(std::make_pair(now, args));
+      i++;
+      if (i==ncalls)
+       break;
+    }
+
     int wait_nsec = wait_time_base;
     if (wait_time_rand>0)
       wait_nsec+=(rand()%wait_time_rand);
@@ -383,9 +394,8 @@ CallGenDialog::~CallGenDialog()
   report(CGDestroy);
 }
 
-void CallGenDialog::onInvite(const AmSipRequest& r) {
+void CallGenDialog::onStart() {
   report(CGCreate);
-  AmSession::onInvite(r);
 }
 
 void CallGenDialog::report(CallGenEvent what) {
diff --git a/apps/examples/call_gen/CallGen.h b/apps/examples/call_gen/CallGen.h
index 1550738..bd8c083 100644
--- a/apps/examples/call_gen/CallGen.h
+++ b/apps/examples/call_gen/CallGen.h
@@ -148,7 +148,7 @@ public:
                int play_rand_digits, int call_time_base, int call_time_rand);
   ~CallGenDialog();
 
-  void onInvite(const AmSipRequest& r);
+  void onStart();
   void onEarlySessionStart();
   void onSessionStart();
   void onBye(const AmSipRequest& req);
diff --git a/apps/examples/call_gen/Readme.callgen 
b/apps/examples/call_gen/Readme.callgen
index 2d0d453..78f648f 100644
--- a/apps/examples/call_gen/Readme.callgen
+++ b/apps/examples/call_gen/Readme.callgen
@@ -32,6 +32,8 @@ callgen - simple call generator
   int    call_time_base   - call timer, base value
   int    call_time_rand   - call timer, random add (total = base + rand)
 
+ [int    ncalls_per_sec   - n calls to schedule per sec ]
+
  method: callGenStats - return some statistics
 
 

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to