Browse code

- removed onSipEvent (not used anywhere...) - simplified the SIP event handling code in AmSession.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1886 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Raphael Coeffic authored on 02/05/2010 12:55:26
Showing 7 changed files
... ...
@@ -629,9 +629,8 @@ void AmSession::process(AmEvent* ev)
629 629
   }
630 630
 
631 631
   AmSipEvent* sip_ev = dynamic_cast<AmSipEvent*>(ev);
632
-  if(sip_ev){	
633
-    DBG("Session received SIP Event\n");
634
-    onSipEvent(sip_ev);
632
+  if(sip_ev){
633
+    (*sip_ev)(&dlg);
635 634
     return;
636 635
   }
637 636
 
... ...
@@ -664,32 +663,6 @@ void AmSession::process(AmEvent* ev)
664 663
 #endif
665 664
 }
666 665
 
667
-
668
-void AmSession::onSipEvent(AmSipEvent* sip_ev)
669
-{
670
-  CALL_EVENT_H(onSipEvent,sip_ev);
671
-
672
-  AmSipRequestEvent* req_ev = dynamic_cast<AmSipRequestEvent*>(sip_ev);
673
-  if(req_ev) {
674
-    dlg.updateStatus(req_ev->req);
675
-    return;
676
-  }
677
-
678
-  AmSipReplyEvent* reply_ev = dynamic_cast<AmSipReplyEvent*>(sip_ev);
679
-  if(reply_ev) {
680
-    dlg.updateStatus(reply_ev->reply);
681
-    return;
682
-  }
683
-
684
-  AmSipTimeoutEvent* to_ev = dynamic_cast<AmSipTimeoutEvent*>(sip_ev);
685
-  if(to_ev) {
686
-    dlg.uasTimeout(to_ev);
687
-    return;
688
-  }
689
-
690
-  ERROR("Unknown SIP Event");
691
-}
692
-
693 666
 void AmSession::onSipRequest(const AmSipRequest& req)
694 667
 {
695 668
   CALL_EVENT_H(onSipRequest,req);
... ...
@@ -456,14 +456,10 @@ public:
456 456
   virtual void onRinging(const AmSipReply& reply){}
457 457
 
458 458
   /**
459
-   * @see AmDialogState
459
+   * onBye is called whenever a BYE request is received. 
460 460
    */
461 461
   virtual void onBye(const AmSipRequest& req);
462 462
 
463
-  /**
464
-   * Entry point for SIP events
465
-   */
466
-  virtual void onSipEvent(AmSipEvent* sip_ev);
467 463
   /** Entry point for SIP Requests   */
468 464
   virtual void onSipRequest(const AmSipRequest& req);
469 465
   /** Entry point for SIP Replies   */
... ...
@@ -38,11 +38,6 @@ bool AmSessionEventHandler::process(AmEvent*)
38 38
   return false;
39 39
 }
40 40
 
41
-bool AmSessionEventHandler::onSipEvent(AmSipEvent*)
42
-{
43
-  return false;
44
-}
45
-
46 41
 bool AmSessionEventHandler::onSipRequest(const AmSipRequest&)
47 42
 {
48 43
   return false;
... ...
@@ -65,7 +65,6 @@ public:
65 65
    */
66 66
   virtual bool process(AmEvent*);
67 67
 
68
-  virtual bool onSipEvent(AmSipEvent*);
69 68
   virtual bool onSipRequest(const AmSipRequest&);
70 69
   virtual bool onSipReply(const AmSipReply&);
71 70
 
... ...
@@ -31,19 +31,24 @@
31 31
 #include "AmEvent.h"
32 32
 #include "AmSipMsg.h"
33 33
 
34
-/** \brief SIP event */
34
+class AmSipDialog;
35
+
36
+/** \brief base class for SIP events */
35 37
 class AmSipEvent: public AmEvent
36 38
 {
37 39
  public:
38
-  AmSipEvent(int id = -1)
39
-    : AmEvent(id)
40
+  AmSipEvent()
41
+    : AmEvent(-1)
40 42
     {}
41 43
 
42 44
   AmSipEvent(const AmSipEvent& ev)
43 45
     : AmEvent(ev)
44 46
     {}
47
+
48
+  virtual void operator() (AmSipDialog* dlg)=0;
45 49
 };
46 50
 
51
+/** \brief UAS reply re-transmission timeout event */
47 52
 class AmSipTimeoutEvent: public AmSipEvent
48 53
 {
49 54
  public:
... ...
@@ -60,9 +65,11 @@ class AmSipTimeoutEvent: public AmSipEvent
60 65
   unsigned int cseq_num;
61 66
   string       cseq_method;
62 67
 
63
- AmSipTimeoutEvent(EvType t, unsigned int cseq_num, const string& cseq_method)
64
-    : AmSipEvent(-1), type(t)
65
-  {}
68
+  AmSipTimeoutEvent(EvType t, unsigned int cseq_num, const string& cseq_method)
69
+    : AmSipEvent(), type(t)
70
+   {}
71
+
72
+  virtual void operator() (AmSipDialog* dlg);
66 73
 };
67 74
 
68 75
 /** \brief SIP request event */
... ...
@@ -72,8 +79,10 @@ class AmSipRequestEvent: public AmSipEvent
72 79
   AmSipRequest req;
73 80
     
74 81
   AmSipRequestEvent(const AmSipRequest& r)
75
-    : AmSipEvent(-1), req(r)
82
+    : AmSipEvent(), req(r)
76 83
     {}
84
+
85
+  virtual void operator() (AmSipDialog* dlg);
77 86
 };
78 87
 
79 88
 /** \brief SIP reply event */
... ...
@@ -84,6 +93,8 @@ class AmSipReplyEvent: public AmSipEvent
84 93
 
85 94
   AmSipReplyEvent(const AmSipReply& r) 
86 95
     : AmSipEvent(),reply(r) {}
96
+
97
+  virtual void operator() (AmSipDialog* dlg);
87 98
 };
88 99
 
89 100
 
... ...
@@ -71,11 +71,6 @@ bool SessionTimer::process(AmEvent* ev)
71 71
   return false;
72 72
 }
73 73
 
74
-bool SessionTimer::onSipEvent(AmSipEvent* ev)
75
-{
76
-  return false;
77
-}
78
-
79 74
 bool SessionTimer::onSipRequest(const AmSipRequest& req)
80 75
 {
81 76
   updateTimer(s,req);
... ...
@@ -137,7 +137,7 @@ class SessionTimer: public AmSessionEventHandler
137 137
   /* @see AmSessionEventHandler */
138 138
   virtual int  configure(AmConfigReader& conf); 
139 139
   virtual bool process(AmEvent*);
140
-  virtual bool onSipEvent(AmSipEvent*);
140
+
141 141
   virtual bool onSipRequest(const AmSipRequest&);
142 142
   virtual bool onSipReply(const AmSipReply&);
143 143