Ergänzungen
This commit is contained in:
parent
4fb818be74
commit
739ecaf317
@ -15,8 +15,9 @@ import model.VoIP;
|
||||
/**
|
||||
*
|
||||
* @author Jan
|
||||
* Anruf annehmen -> Evt muss noch gelöscht werden falls nichtmehr angerufen wird,
|
||||
* Anruf annehmen -> Event muss noch gelöscht werden falls nichtmehr angerufen wird,
|
||||
* welches Kriterium???
|
||||
* -> evtl. über "Undo" aktion
|
||||
*/
|
||||
public class CommandAnnehmen implements CommandInterface
|
||||
{
|
||||
|
@ -52,15 +52,20 @@ public class VoIP implements SipListenerExt
|
||||
Properties properties; // Other properties.
|
||||
|
||||
private int counter = 10;
|
||||
|
||||
|
||||
|
||||
private int myPort = 5060;
|
||||
private String myName = "129";
|
||||
private String protocolTyp = "UDP";
|
||||
private String myIPAddress;
|
||||
private String proxyAddress;
|
||||
|
||||
Boolean invite;
|
||||
|
||||
Boolean invite; //Bool für SDP falls ich anrufe
|
||||
|
||||
//Hilfsvariablen wenn ich angerufen werde. evtl. noch optimieren
|
||||
RequestEvent evtWerdeAngerufen;
|
||||
Boolean werdeAngerufen;
|
||||
private int countWerdeAngerufen;
|
||||
|
||||
int tag = (new Random()).nextInt();
|
||||
private int branch = hashCode();
|
||||
@ -70,14 +75,18 @@ public class VoIP implements SipListenerExt
|
||||
public VoIP(Hauptfenster view) //Konstruktor für eigene Daten
|
||||
{
|
||||
this.view = view;
|
||||
invite = true;
|
||||
proxyAddress = "";
|
||||
|
||||
countWerdeAngerufen = 0;
|
||||
evtWerdeAngerufen = null;
|
||||
werdeAngerufen =false;
|
||||
|
||||
try
|
||||
{
|
||||
//wird an sich erstmal nicht gebraucht aber später sinnvoll um eigene Daten zu initialisieren
|
||||
String abc = InetAddress.getLocalHost().getHostAddress();
|
||||
invite = true;
|
||||
proxyAddress = "";
|
||||
evtWerdeAngerufen = null;
|
||||
|
||||
|
||||
this.myIPAddress = InetAddress.getLocalHost().getHostAddress();
|
||||
|
||||
this.sipFactory = SipFactory.getInstance();
|
||||
@ -91,7 +100,8 @@ public class VoIP implements SipListenerExt
|
||||
this.listeningPoint = this.sipStack.createListeningPoint(this.myIPAddress, this.myPort, this.protocolTyp);
|
||||
this.sipProvider = this.sipStack.createSipProvider(this.listeningPoint);
|
||||
this.sipProvider.addSipListener(this);
|
||||
this.contactAddress = this.addressFactory.createAddress("sip:129@" + this.myIPAddress + ":" + this.myPort); //+ ":" + this.myPort
|
||||
//this.contactAddress = this.addressFactory.createAddress("sip:129@" + this.myIPAddress + ":" + this.myPort); //+ ":" + this.myPort
|
||||
this.contactAddress = this.addressFactory.createAddress("sip:" + myName+ "@" + this.myIPAddress + ":" + this.myPort);
|
||||
this.contactHeader = this.headerFactory.createContactHeader(contactAddress);
|
||||
|
||||
}
|
||||
@ -114,7 +124,6 @@ public class VoIP implements SipListenerExt
|
||||
lg.info("Vorbereiten des Registrierungs Headers");
|
||||
proxyAddress = serverIP + ":" + serverPort;
|
||||
Address addressto = this.addressFactory.createAddress("sip:" + proxyAddress); //evtl. mit Port: sip:192.168.100.11:5060
|
||||
//Address addressto = this.addressFactory.createAddress("sip:192.168.100.11");
|
||||
ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag
|
||||
URI requestURI = addressto.getURI();
|
||||
CallIdHeader callId = this.sipProvider.getNewCallId();
|
||||
@ -138,10 +147,7 @@ public class VoIP implements SipListenerExt
|
||||
int serverPort) throws ParseException, InvalidArgumentException, SipException, SdpException
|
||||
{
|
||||
invite = true;
|
||||
|
||||
|
||||
|
||||
Address addressto = this.addressFactory.createAddress("sip:" + sipaddresse + "@" + proxyaddresse); //evtl. mit Port: sip:192.168.100.11:5060
|
||||
Address addressto = this.addressFactory.createAddress("sip:" + sipaddresse + "@" + proxyaddresse);
|
||||
//Address addressto = this.addressFactory.createAddress("sip:121@192.168.100.11");
|
||||
ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag
|
||||
URI requestURI = addressto.getURI();
|
||||
@ -209,10 +215,24 @@ public class VoIP implements SipListenerExt
|
||||
//Aktive Kommunikation
|
||||
else if ((Request.INVITE).equals(requestEvent.getRequest().getMethod())) // Invite von anderem Benutzer
|
||||
{
|
||||
countWerdeAngerufen++;
|
||||
FromHeader abc = (FromHeader) requestEvent.getRequest().getHeader("From");
|
||||
view.getTxtArea().append("Werde von " + abc.getAddress() + " angerufen\n");
|
||||
evtWerdeAngerufen = requestEvent;
|
||||
lg.info("Hab Invitation bekommen");
|
||||
System.out.println(countWerdeAngerufen);
|
||||
if(countWerdeAngerufen<7)
|
||||
{
|
||||
werdeAngerufen = true;
|
||||
lg.info("Hab Invitation bekommen");
|
||||
view.getTxtArea().append("Werde von " + abc.getAddress() + " angerufen\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
werdeAngerufen = false;
|
||||
lg.info("Leider waren Sie nicht erreichbar");
|
||||
view.getTxtArea().append("Sie waren nicht erreichbar\n");
|
||||
countWerdeAngerufen = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((Request.ACK).equals(requestEvent.getRequest().getMethod()))
|
||||
{
|
||||
@ -327,13 +347,14 @@ public class VoIP implements SipListenerExt
|
||||
public void annehmen() //Fehlende Bedingung
|
||||
{
|
||||
RequestEvent requestEvent;
|
||||
if ((requestEvent=evtWerdeAngerufen) != null)
|
||||
if ((requestEvent=evtWerdeAngerufen) != null && werdeAngerufen==true)
|
||||
{
|
||||
countWerdeAngerufen =0;
|
||||
|
||||
try
|
||||
{
|
||||
//Trying Message to Server (Response Trying)
|
||||
|
||||
|
||||
Response responsetry = this.messageFactory.createResponse(100, requestEvent.getRequest());
|
||||
responsetry.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via"));
|
||||
responsetry.addHeader((FromHeader) requestEvent.getRequest().getHeader("From"));
|
||||
@ -388,9 +409,9 @@ public class VoIP implements SipListenerExt
|
||||
ContentTypeHeader content = headerFactory.createContentTypeHeader("application", "sdp");
|
||||
okandSDP.addHeader(content);
|
||||
okandSDP.setContent(createSDPHeader(), content);
|
||||
System.out.println(okandSDP);
|
||||
this.sipProvider.sendResponse(okandSDP);
|
||||
|
||||
view.getTxtArea().append("Telefonat beginnt\n");
|
||||
evtWerdeAngerufen =null;
|
||||
}
|
||||
catch (ParseException | SipException | SdpException ex)
|
||||
@ -399,6 +420,9 @@ public class VoIP implements SipListenerExt
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
view.getTxtArea().append("Zur Zeit gibt es keinen Anruf\n");
|
||||
|
||||
}
|
||||
|
||||
//Get Methoden falls man mal die Parameter braucht
|
||||
@ -425,22 +449,26 @@ public class VoIP implements SipListenerExt
|
||||
@Override
|
||||
public void processTimeout(TimeoutEvent timeoutEvent)
|
||||
{
|
||||
view.getTxtArea().append("processTimeout\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIOException(IOExceptionEvent exceptionEvent)
|
||||
{
|
||||
view.getTxtArea().append("processIOException\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processTransactionTerminated(
|
||||
TransactionTerminatedEvent transactionTerminatedEvent)
|
||||
{
|
||||
view.getTxtArea().append("processTransactionTerminated\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processDialogTerminated(
|
||||
DialogTerminatedEvent dialogTerminatedEvent)
|
||||
{
|
||||
view.getTxtArea().append("processDialogTerminated\n");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user