@@ -0,0 +1,19 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package model; | |||
/** | |||
* | |||
* @author Jan | |||
*/ | |||
public class SIP | |||
{ | |||
public SIP() | |||
{ | |||
} | |||
} |
@@ -15,52 +15,41 @@ import javax.sip.SipException; | |||
import javax.sip.header.AllowEventsHeader; | |||
import javax.sip.header.AllowHeader; | |||
import javax.sip.header.CSeqHeader; | |||
import javax.sip.header.ContactHeader; | |||
import javax.sip.header.FromHeader; | |||
import javax.sip.header.HeaderFactory; | |||
import javax.sip.header.ToHeader; | |||
import javax.sip.header.ViaHeader; | |||
import javax.sip.message.MessageFactory; | |||
import javax.sip.message.Response; | |||
import logger.OhmLogger; | |||
/** | |||
* | |||
* @author Jan | |||
*/ | |||
public class SIPRinging implements Runnable | |||
public class SIP180Ringing implements Runnable | |||
{ | |||
private RequestEvent evtubergabe; | |||
private ExecutorService threadring; | |||
private boolean run; | |||
private Response responsering; | |||
private MessageFactory messageFactory; | |||
private HeaderFactory headerFactory; | |||
private String myTag; | |||
private String proxyTag; | |||
public static final Logger lg = OhmLogger.getLogger(); | |||
//private SubmissionPublisher<Integer> publisherZahl; | |||
public SIPRinging(RequestEvent evtubergabe) | |||
public SIP180Ringing(RequestEvent evtubergabe, String myTag, ContactHeader contact) | |||
{ | |||
this.evtubergabe = evtubergabe; | |||
threadring = Executors.newSingleThreadExecutor(); | |||
try | |||
{ | |||
responsering = this.messageFactory.createResponse(180, evtubergabe.getRequest()); | |||
} | |||
catch (Exception ex) | |||
{ | |||
lg.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
public void start() | |||
{ | |||
run = true; | |||
threadring.submit(this); | |||
} | |||
public void stop() | |||
{ | |||
run = false; | |||
} | |||
public void createRingingHeader() | |||
{ | |||
try | |||
{ | |||
responsering.addHeader((ViaHeader) evtubergabe.getRequest().getHeader("Via")); | |||
responsering.addHeader((FromHeader) evtubergabe.getRequest().getHeader("From")); | |||
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); | |||
@@ -69,19 +58,32 @@ public class SIPRinging implements Runnable | |||
proxyTag = temptoring.getTag(); | |||
temptoring.setTag(String.valueOf(this.myTag)); | |||
responsering.addHeader(temptoring); | |||
cSequenz = ((CSeqHeader) evtubergabe.getRequest().getHeader("Cseq")).getSeqNumber(); | |||
long cSequenz = ((CSeqHeader) evtubergabe.getRequest().getHeader("Cseq")).getSeqNumber(); | |||
responsering.addHeader((CSeqHeader) evtubergabe.getRequest().getHeader("Cseq")); | |||
responsering.addHeader(contactHeader); | |||
responsering.addHeader(contact); | |||
responsering.addHeader(allow); | |||
AllowEventsHeader allowevent = this.headerFactory.createAllowEventsHeader("talk,hold,refer,call-info");// für was gebraucht | |||
responsering.addHeader(allowevent); | |||
lg.info("Ringing Header erfolgreich erstellt"); | |||
} | |||
catch (Exception ex) | |||
{ | |||
lg.info("Fehler bei erstellen des Ringing Headers"); | |||
lg.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
public void start() | |||
{ | |||
run = true; | |||
threadring.submit(this); | |||
} | |||
public void stop() | |||
{ | |||
run = false; | |||
} | |||
@Override | |||
public void run() | |||
{ | |||
@@ -93,7 +95,7 @@ public class SIPRinging implements Runnable | |||
} | |||
catch (SipException ex) | |||
{ | |||
Logger.getLogger(SIPRinging.class.getName()).log(Level.SEVERE, null, ex); | |||
Logger.getLogger(SIP180Ringing.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
try | |||
{ |
@@ -0,0 +1,63 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package model; | |||
import java.util.logging.Logger; | |||
import javax.sip.RequestEvent; | |||
import javax.sip.header.AllowEventsHeader; | |||
import javax.sip.header.AllowHeader; | |||
import javax.sip.header.CSeqHeader; | |||
import javax.sip.header.CallIdHeader; | |||
import javax.sip.header.ContactHeader; | |||
import javax.sip.header.FromHeader; | |||
import javax.sip.header.HeaderFactory; | |||
import javax.sip.header.ToHeader; | |||
import javax.sip.header.ViaHeader; | |||
import javax.sip.message.MessageFactory; | |||
import javax.sip.message.Response; | |||
import logger.OhmLogger; | |||
/** | |||
* | |||
* @author Jan | |||
*/ | |||
public class SIP200Ok | |||
{ | |||
private Response response; | |||
private static final Logger lg200Ok = OhmLogger.getLogger(); | |||
public SIP200Ok(MessageFactory messageFactory, RequestEvent requestEvent, | |||
ContactHeader contactHeader, HeaderFactory headerFactory) | |||
{ | |||
try | |||
{ | |||
Response response = messageFactory.createResponse(200, requestEvent.getRequest()); | |||
response.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via")); | |||
response.addHeader((FromHeader) requestEvent.getRequest().getHeader("From")); | |||
response.addHeader((ToHeader) requestEvent.getRequest().getHeader("To")); | |||
response.addHeader((CallIdHeader) requestEvent.getRequest().getHeader("Call-ID")); | |||
response.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq")); | |||
response.addHeader(contactHeader); | |||
AllowHeader allow = headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); | |||
AllowEventsHeader allowevents = headerFactory.createAllowEventsHeader("talk,hold,refer,call-info"); | |||
response.addHeader((CallIdHeader) requestEvent.getRequest().getHeader("Call-ID")); | |||
response.addHeader(allow); | |||
response.addHeader(allowevents); | |||
lg200Ok.info("200Ok Header erfolgreich erstellt"); | |||
} | |||
catch (Exception ex) | |||
{ | |||
lg200Ok.getLogger(SIPmodel.class.getName()).log(Level.SEVERE, null, ex); | |||
} | |||
} | |||
/** | |||
* @return the response | |||
*/ | |||
public Response getResponse() | |||
{ | |||
return response; | |||
} | |||
} |
@@ -54,8 +54,8 @@ public class SIPmodel implements SipListenerExt | |||
private String[][] codecs; //unterstütze Codecs[RTP-Parameter][CodecBezeichnung] | |||
public int myPort = 5060; | |||
public String myName = "129"; | |||
private int myPort = 5060; | |||
private String myName = "129"; | |||
public String protocolTyp = "UDP"; | |||
public String myIPAddress; | |||
public String proxyAddress; | |||
@@ -69,9 +69,9 @@ public class SIPmodel implements SipListenerExt | |||
private int countWerdeAngerufen; | |||
public long cSequenz = 1; | |||
public String proxyTag; | |||
public int myTag = (new Random()).nextInt(); | |||
public int branch = hashCode(); | |||
private String proxyTag; | |||
private int myTag = (new Random()).nextInt(); | |||
private int branch = hashCode(); | |||
public Address contactAddress; | |||
public ContactHeader contactHeader; | |||
@@ -336,15 +336,15 @@ public class SIPmodel implements SipListenerExt | |||
public Response create200Ok(RequestEvent requestEvent) throws ParseException | |||
{ | |||
Response response = this.messageFactory.createResponse(200, requestEvent.getRequest()); | |||
Response response = messageFactory.createResponse(200, requestEvent.getRequest()); | |||
response.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via")); | |||
response.addHeader((FromHeader) requestEvent.getRequest().getHeader("From")); | |||
response.addHeader((ToHeader) requestEvent.getRequest().getHeader("To")); | |||
response.addHeader((CallIdHeader) requestEvent.getRequest().getHeader("Call-ID")); | |||
response.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq")); | |||
response.addHeader(contactHeader); | |||
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); | |||
AllowEventsHeader allowevents = this.headerFactory.createAllowEventsHeader("talk,hold,refer,call-info"); | |||
AllowHeader allow = headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); | |||
AllowEventsHeader allowevents = headerFactory.createAllowEventsHeader("talk,hold,refer,call-info"); | |||
response.addHeader((CallIdHeader) requestEvent.getRequest().getHeader("Call-ID")); | |||
response.addHeader(allow); | |||
response.addHeader(allowevents); | |||
@@ -425,7 +425,7 @@ public class SIPmodel implements SipListenerExt | |||
RequestEvent requestEvent; | |||
if ((requestEvent = evtWerdeAngerufen) != null && werdeAngerufen == true) | |||
{ | |||
countWerdeAngerufen = 0; | |||
countWerdeAngerufen = 0; | |||
try | |||
{ | |||
@@ -594,4 +594,60 @@ public class SIPmodel implements SipListenerExt | |||
{ | |||
//view.getTxtArea().append("processDialogTerminated\n"); | |||
} | |||
/** | |||
* @param myPort the myPort to set | |||
*/ | |||
public void setMyPort(int myPort) | |||
{ | |||
this.myPort = myPort; | |||
} | |||
/** | |||
* @return the myName | |||
*/ | |||
public String getMyName() | |||
{ | |||
return myName; | |||
} | |||
/** | |||
* @return the proxyTag | |||
*/ | |||
public String getProxyTag() | |||
{ | |||
return proxyTag; | |||
} | |||
/** | |||
* @param proxyTag the proxyTag to set | |||
*/ | |||
public void setProxyTag(String proxyTag) | |||
{ | |||
this.proxyTag = proxyTag; | |||
} | |||
/** | |||
* @return the myTag | |||
*/ | |||
public int getMyTag() | |||
{ | |||
return myTag; | |||
} | |||
/** | |||
* @param myTag the myTag to set | |||
*/ | |||
public void setMyTag(int myTag) | |||
{ | |||
this.myTag = myTag; | |||
} | |||
/** | |||
* @return the branch | |||
*/ | |||
public int getBranch() | |||
{ | |||
return branch; | |||
} | |||
} |