title: Pjsip Use Sip-Specific Event Notification for Notify message
body: <p>I want to implement Notify event CallBack in CsipSimple here is the C code i have written</p>
  
  <p>My C/C++ files </p>
  
  <p>The pjsip_event_notification.h file</p>
  
  <pre><code>#include &lt;pjsip-simple/evsub.h&gt;
  
  class EventCallBack {
  
  public:
          virtual ~EventCallBack() {}
  
          virtual void on_evsub_state(pjsip_evsub *sub, pjsip_event *event){}
          virtual void on_tsx_state(pjsip_evsub *sub, pjsip_transaction *tsx,
                          pjsip_event *event){}
          virtual void on_rx_refresh(pjsip_evsub *sub, pjsip_rx_data *rdata,
                          int p_st_code, pj_str_t **p_st_text, pjsip_hdr *res_hdr,
                          pjsip_msg_body **p_body){}
          virtual void on_rx_notify(pjsip_evsub *sub, pjsip_rx_data *rdata, int *p_st_code,
                          pj_str_t **p_st_text, pjsip_hdr *res_hdr, pjsip_msg_body **p_body){}
          virtual void on_client_refresh(pjsip_evsub *sub){}
          virtual void on_server_timeout(pjsip_evsub *sub){}
  
  };
  extern "C" {
  void setEventCallbackObject(EventCallBack* eventCallBack);
  }
  </code></pre>
  
  <p>pjsip_event_notification.cpp file </p>
  
  <pre><code>#include "pjsip_event_notification.h"
  static EventCallBack* registeredCallbackObject = NULL;
  
  extern "C" {
  
  
   void on_evsub_state_wrapper(pjsip_evsub *sub, pjsip_event *event){
                  registeredCallbackObject-&gt;on_evsub_state(sub,event);
  
   }
   void on_tsx_state_wrapper(pjsip_evsub *sub, pjsip_transaction *tsx,
                  pjsip_event *event){
           registeredCallbackObject-&gt; on_tsx_state(sub,tsx,event);
   }
   void on_rx_refresh_wrapper(pjsip_evsub *sub, pjsip_rx_data *rdata,
                  int p_st_code, pj_str_t **p_st_text, pjsip_hdr *res_hdr,
                  pjsip_msg_body **p_body){
           registeredCallbackObject-&gt;on_rx_refresh(sub,rdata,p_st_code,p_st_text,res_hdr,p_body);
  
   }
   void on_rx_notify_wrapper(pjsip_evsub *sub, pjsip_rx_data *rdata, int *p_st_code,
                  pj_str_t **p_st_text, pjsip_hdr *res_hdr, pjsip_msg_body **p_body){
           registeredCallbackObject-&gt;on_rx_notify(sub,rdata,p_st_code,p_st_text,res_hdr,p_body);
   }
   void on_client_refresh_wrapper(pjsip_evsub *sub){
           registeredCallbackObject-&gt;on_client_refresh(sub);
   }
   void on_server_timeout_wrapper(pjsip_evsub *sub){
           registeredCallbackObject-&gt;on_server_timeout(sub);
   }
  
  // struct event_callback wrapper_callback_event_struct = {
  //               &amp;on_evsub_state_wrapper,
  //               &amp;on_tsx_state_wrapper,
  //               &amp;on_rx_refresh_wrapper,
  //               &amp;on_rx_notify_wrapper,
  //               &amp;on_client_refresh_wrapper,
  //               &amp;on_server_timeout_wrapper
  // };
  
  
  
   void setEventCallbackObject(EventCallBack* eventCallBack){
           registeredCallbackObject=eventCallBack;
   }
  </code></pre>
  
  <p>and the Java files used to implement </p>
  
  <pre><code>package com.csipsimple.events;
  
  import org.pjsip.pjsua.EventCallBack;
  import org.pjsip.pjsua.SWIGTYPE_p_int;
  import org.pjsip.pjsua.SWIGTYPE_p_p_pj_str_t;
  import org.pjsip.pjsua.SWIGTYPE_p_p_pjsip_msg_body;
  import org.pjsip.pjsua.SWIGTYPE_p_pjsip_evsub;
  import org.pjsip.pjsua.SWIGTYPE_p_pjsip_hdr;
  import org.pjsip.pjsua.SWIGTYPE_p_pjsip_rx_data;
  import org.pjsip.pjsua.SWIGTYPE_p_pjsip_transaction;
  import org.pjsip.pjsua.pjsip_event;
  
  public class EventNotify extends EventCallBack{
  
          @Override
          public void on_evsub_state(SWIGTYPE_p_pjsip_evsub sub, pjsip_event event) {
  
                  System.out.println("EventNotify on_evsub_state");
                  super.on_evsub_state(sub, event);
          }
  
          @Override
          public void on_tsx_state(SWIGTYPE_p_pjsip_evsub sub,
                          SWIGTYPE_p_pjsip_transaction tsx, pjsip_event event) {
                  System.out.println("EventNotify on_tsx_state");
                  super.on_tsx_state(sub, tsx, event);
          }
  
          @Override
          public void on_rx_refresh(SWIGTYPE_p_pjsip_evsub sub,
                          SWIGTYPE_p_pjsip_rx_data rdata, int p_st_code,
                          SWIGTYPE_p_p_pj_str_t p_st_text, SWIGTYPE_p_pjsip_hdr res_hdr,
                          SWIGTYPE_p_p_pjsip_msg_body p_body) {
                  System.out.println("EventNotify on_rx_refresh");
                  super.on_rx_refresh(sub, rdata, p_st_code, p_st_text, res_hdr, p_body);
          }
  
          @Override
          public void on_rx_notify(SWIGTYPE_p_pjsip_evsub sub,
                          SWIGTYPE_p_pjsip_rx_data rdata, SWIGTYPE_p_int p_st_code,
                          SWIGTYPE_p_p_pj_str_t p_st_text, SWIGTYPE_p_pjsip_hdr res_hdr,
                          SWIGTYPE_p_p_pjsip_msg_body p_body) {
                  System.out.println("EventNotify on_rx_notify");
                  super.on_rx_notify(sub, rdata, p_st_code, p_st_text, res_hdr, p_body);
          }
  
          @Override
          public void on_client_refresh(SWIGTYPE_p_pjsip_evsub sub) {
                  System.out.println("EventNotify on_client_refresh");
                  super.on_client_refresh(sub);
          }
  
          @Override
          public void on_server_timeout(SWIGTYPE_p_pjsip_evsub sub) {
                  System.out.println("EventNotify on_server_timeout");
                  super.on_server_timeout(sub);
          }
  
  }
  
  }
  </code></pre>
  
  <p>I wanted to ask how can i get call back to these methods</p>
  
  <p>The complete Src can be cloned at 
  git clone <a href="https://Rs9766@bitbucket.org/Rs9766/csipsimple_virtualbox.git" rel="nofollow">https://Rs9766@bitbucket.org/Rs9766/csipsimple_virtualbox.git</a></p>