Replace `DispatchSessionEvent` with `NotifySessionHang` on sessions. (#33259)

* Replace `Dispatch event` with `NotifySessionHang` on sessions.

Only a single event was ever dispatched and the pattern of passing
in pointers to member methods was not used anywhere else and resulted
in fairly unique code.

Spelling out the `NotifySessionHang` explicitly seems to simplify
maintainability.

* Update src/transport/Session.h

Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>

---------

Co-authored-by: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com>
diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp
index bca044d..554e5fb 100644
--- a/src/messaging/ExchangeContext.cpp
+++ b/src/messaging/ExchangeContext.cpp
@@ -485,7 +485,7 @@
             {
                 mSession->AsSecureSession()->MarkAsDefunct();
             }
-            mSession->DispatchSessionEvent(&SessionDelegate::OnSessionHang);
+            mSession->NotifySessionHang();
         }
     }
 
diff --git a/src/messaging/ReliableMessageMgr.cpp b/src/messaging/ReliableMessageMgr.cpp
index 3827fd0..1704906 100644
--- a/src/messaging/ReliableMessageMgr.cpp
+++ b/src/messaging/ReliableMessageMgr.cpp
@@ -158,7 +158,7 @@
                 {
                     session->AsSecureSession()->MarkAsDefunct();
                 }
-                session->DispatchSessionEvent(&SessionDelegate::OnSessionHang);
+                session->NotifySessionHang();
             }
 
             // Do not StartTimer, we will schedule the timer at the end of the timer handler.
diff --git a/src/transport/Session.h b/src/transport/Session.h
index d9840ec..87937ee 100644
--- a/src/transport/Session.h
+++ b/src/transport/Session.h
@@ -114,8 +114,8 @@
 
     Transport::Session * operator->() const { return &mSession.Value().Get(); }
 
-    // There is not delegate, nothing to do here
-    virtual void DispatchSessionEvent(SessionDelegate::Event event) {}
+    // There is no delegate, nothing to do here
+    virtual void OnSessionHang() {}
 
 protected:
     // Helper for use by the Grab methods.
@@ -147,7 +147,7 @@
             SessionHolder::ShiftToSession(session);
     }
 
-    void DispatchSessionEvent(SessionDelegate::Event event) override { (mDelegate.*event)(); }
+    void OnSessionHang() override { mDelegate.OnSessionHang(); }
 
 private:
     SessionDelegate & mDelegate;
@@ -237,7 +237,7 @@
     void SetTCPConnection(ActiveTCPConnectionState * conn) { mTCPConnection = conn; }
 #endif // INET_CONFIG_ENABLE_TCP_ENDPOINT
 
-    void DispatchSessionEvent(SessionDelegate::Event event)
+    void NotifySessionHang()
     {
         // Holders might remove themselves when notified.
         auto holder = mHolders.begin();
@@ -245,7 +245,7 @@
         {
             auto cur = holder;
             ++holder;
-            cur->DispatchSessionEvent(event);
+            cur->OnSessionHang();
         }
     }
 
diff --git a/src/transport/SessionDelegate.h b/src/transport/SessionDelegate.h
index 503aaa2..8de535a 100644
--- a/src/transport/SessionDelegate.h
+++ b/src/transport/SessionDelegate.h
@@ -51,8 +51,6 @@
      */
     virtual NewSessionHandlingPolicy GetNewSessionHandlingPolicy() { return NewSessionHandlingPolicy::kShiftToNewSession; }
 
-    using Event = void (SessionDelegate::*)();
-
     /**
      * @brief
      *   Called when a session is releasing. Callees SHALL NOT make synchronous calls into SessionManager to allocate a new session.