Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.96 KB | None | 0 0
  1. package org.gets.app.jar;
  2.  
  3. import javax.sip.message.Message;
  4. import javax.sip.message.Response;
  5.  
  6. import org.slf4j.Logger;
  7. import org.slf4j.LoggerFactory;
  8.  
  9. import com.hp.opencall.ngin.scif.Call;
  10. import com.hp.opencall.ngin.scif.CallLeg;
  11. import com.hp.opencall.ngin.scif.CallUser;
  12. import com.hp.opencall.ngin.scif.Cause;
  13. import com.hp.opencall.ngin.scif.Contact;
  14. import com.hp.opencall.ngin.scif.PollEvent;
  15. import com.hp.opencall.ngin.scif.ScifEvent;
  16. import com.hp.opencall.ngin.scif.ScifException;
  17. import com.hp.opencall.ngin.scif.ScifFactory;
  18. import com.hp.opencall.ngin.scif.resources.IvrCallLeg;
  19. import com.hp.opencall.ngin.scif.resources.RawMediaCallLeg;
  20. import com.hp.opencall.ngin.scif.resources.RawMediaCallLeg.RawBytesMediaUser;
  21. import com.hp.opencall.ngin.scif.resources.RawMrfContact;
  22. import com.hp.opencall.seeconnector.diameterbase.api.event.DiameterBaseEvent;
  23. import com.hp.opencall.seeconnector.diameterbase.api.event.DiameterBaseMessageListener;
  24. import com.hp.opencall.ngin.scif.parameters.SipRawMessageContent;
  25.  
  26. public class GetsCallUser implements CallUser,  RawBytesMediaUser, DiameterBaseMessageListener  {
  27.    
  28.     private static final Logger _log = LoggerFactory.getLogger(GetsCallUser.class.getPackage().getName());
  29.  
  30.     private final Call call;
  31.     private IvrCallLeg ivrCallLeg;  
  32.     private static final String IVRCONTACT_SRF_NAME_SIP_RAW       = "IMSMRF";
  33.  
  34.     public GetsCallUser(Call aCall) {
  35.    
  36.         call = aCall;
  37.      
  38.     }
  39.  
  40.     public void callStart(Cause aCause, CallLeg aFirstLeg, Contact aCalledParty) {
  41.        
  42.         _log.info("[GETS]["+this.getClass().getName()+"]:callStart()" + aCause.toString() + ".");
  43.        
  44.         try {
  45.            
  46.             RawMrfContact rawContact = ScifFactory.instance().getResourceContact(call, RawMrfContact.class, IVRCONTACT_SRF_NAME_SIP_RAW);
  47.             call.forwardCall(rawContact);
  48.            
  49.             _log.info("[GETS]["+this.getClass().getName()+"]:callStart()" + rawContact.getName() + "|"+rawContact.getLegName()+"|"+rawContact.getAddress());
  50.            
  51.         } catch (ScifException e) {
  52.             e.printStackTrace();
  53.         }
  54.     }
  55.  
  56.     public void callEarlyAnswered(CallLeg aNewLeg) {
  57.        
  58.         _log.info("[GETS]["+this.getClass().getName()+"]:Call early-answered.");
  59.        
  60.     }
  61.  
  62.     public void callAnswered(Cause aCause, CallLeg aNewLeg) {
  63.        
  64.         _log.info("[GETS]["+this.getClass().getName()+"]:"+"[" + call.getId() + "] Call answered");
  65.        
  66.         RawMediaCallLeg ivrLeg = (RawMediaCallLeg)aNewLeg;
  67.         ivrLeg.setRawBytesMediaUser(this);
  68.        
  69.         // Build the media operation payload.
  70.         SipRawMessageContent mediaOperation = null ;
  71.        
  72.         try {
  73.             ivrLeg.performMediaOperation(mediaOperation);
  74.         } catch (ScifException e) {
  75.             // TODO Auto-generated catch block
  76.             e.printStackTrace();
  77.         }
  78.        
  79.     }
  80.  
  81.     public void callPoll(ScifEvent anEvent) {
  82.        
  83.         if (anEvent instanceof PollEvent) {
  84.              ((PollEvent)anEvent).reject(Cause.NOT_APPLICABLE);
  85.         }
  86.     }
  87.  
  88.     public void callEnd(Cause aCause) {
  89.    
  90.         _log.info("[GETS]["+this.getClass().getName()+"]:"+"[" + call.getId() + "] FMS call end, with cause " + aCause);
  91.    
  92.     }
  93.  
  94.     public void collectComplete(Cause aCause, String arg1){
  95.    
  96.         _log.info("[GETS]["+this.getClass().getName()+"]:"+"collectComplete()-->");
  97.        
  98.     }
  99.  
  100.     public void playComplete(Cause aCause) {
  101.  
  102.         _log.info("[GETS]["+this.getClass().getName()+"]:"+"playComplete()-->");
  103.        
  104.          try {
  105.              ivrCallLeg.release(Cause.IVR_DISCONNECTED);
  106.          } catch (ScifException e) {
  107.             // TODO Auto-generated catch block
  108.             e.printStackTrace();
  109.         }
  110.     }
  111.    
  112.     public String getCallId() {
  113.         return call.getId();
  114.     }
  115.  
  116.     public void mediaOperationNotification(SipRawMessageContent arg0, Message arg1) {
  117.         // TODO Auto-generated method stub
  118.    
  119.        
  120.        
  121.     }
  122.  
  123.     public void mediaOperationRejected(int arg0, Response arg1) {
  124.         // TODO Auto-generated method stub
  125.        
  126.     }
  127.  
  128.     @Override
  129.     public void requestReceived(DiameterBaseEvent arg0) {
  130.         // TODO Auto-generated method stub
  131.        
  132.     }
  133.  
  134.     @Override
  135.     public void responseReceived(DiameterBaseEvent arg0) {
  136.         // TODO Auto-generated method stub
  137.        
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement