Browse Source

Ergänzungen

RTP
Normal 5 years ago
parent
commit
4fb818be74

+ 2
- 1
src/controller/CommandController.java View File

@@ -19,7 +19,8 @@ import model.VoIP;

/**
*
* @author Normal
* @author Jan
* Controller für Buttons und zuweisung der commands an die jeweiligen Buttons
*/
public class CommandController implements ActionListener
{

+ 2
- 1
src/controller/CommandInterface.java View File

@@ -7,7 +7,8 @@ package controller;
/**
*
* @author Normal
* @author Jan
* wird an sich noch nicht gebraucht aber später noch nützlich
*/
public interface CommandInterface
{

+ 2
- 1
src/controller/CommandInvoker.java View File

@@ -11,7 +11,8 @@ import java.util.Stack;

/**
*
* @author Normal
* @author Jan
* Invoker für alle Commands zur übersichtlichkeit, evtl. undo anruf?
*/
public class CommandInvoker
{

+ 6
- 12
src/controller/commands/CommandAnnehmen.java View File

@@ -14,7 +14,9 @@ import model.VoIP;

/**
*
* @author Normal
* @author Jan
* Anruf annehmen -> Evt muss noch gelöscht werden falls nichtmehr angerufen wird,
* welches Kriterium???
*/
public class CommandAnnehmen implements CommandInterface
{
@@ -29,19 +31,11 @@ public class CommandAnnehmen implements CommandInterface
@Override
public void execute()
{/*
try
{
{
view.getTxtArea().append("Anruf von" + "xxxxxx" + " annehmen?\n");
model.acceptcall(view.getTxtcallIP().getText(),view.getTxtServerIP().getText(), 5078);
}
catch (ParseException|InvalidArgumentException|SdpException|SipException ex)
{
view.getTxtArea().append("Anruf konnte nicht angenommen werden\n");
lginvite.getLogger(CommandAnnehmen.class.getName()).log(Level.SEVERE, null, ex);
model.annehmen();
}
*/
}
}
@Override
public void undo()
{

+ 2
- 1
src/controller/commands/CommandBeenden.java View File

@@ -14,7 +14,8 @@ import model.VoIP;

/**
*
* @author Normal
* @author Jan
* Muss noch komplett implementiert werden
*/
public class CommandBeenden implements CommandInterface
{

+ 2
- 1
src/controller/commands/CommandInvite.java View File

@@ -19,7 +19,8 @@ import model.VoIP;

/**
*
* @author Normal
* @author Jan
* Fehlende Ergänzungen(timer nach 10 sec für abbruchbedingung + bedingung falls angenommen wurde -> Boolean)
*/
public class CommandInvite implements CommandInterface
{

+ 2
- 1
src/controller/commands/CommandRegister.java View File

@@ -18,7 +18,8 @@ import model.VoIP;

/**
*
* @author Normal
* @author Jan
* Registrierung auf Proxy Server
*/
public class CommandRegister implements CommandInterface
{

+ 102
- 84
src/model/VoIP.java View File

@@ -35,7 +35,8 @@ import logger.OhmLogger;

/**
*
* @author Normal
* @author Jan
* komplettes Model für VoIP
*/
public class VoIP implements SipListenerExt
{
@@ -50,15 +51,16 @@ public class VoIP implements SipListenerExt
ListeningPoint listeningPoint; // SIP listening IP address/port.
Properties properties; // Other properties.

private int counter;
private int counter = 10;
private int myPort = 5060;

private String myName = "129";
private String protocolTyp = "UDP";
private String myIPAddress;
private String proxyAddress;
Boolean invite;
RequestEvent evtWerdeAngerufen;
int tag = (new Random()).nextInt();
private int branch = hashCode();
@@ -73,6 +75,9 @@ public class VoIP implements SipListenerExt
//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();
@@ -89,7 +94,6 @@ public class VoIP implements SipListenerExt
this.contactAddress = this.addressFactory.createAddress("sip:129@" + this.myIPAddress + ":" + this.myPort); //+ ":" + this.myPort
this.contactHeader = this.headerFactory.createContactHeader(contactAddress);

//proxyAddress = "";
}
catch (Exception e)
{
@@ -108,8 +112,8 @@ public class VoIP implements SipListenerExt
public void sendRegister(String serverIP, int serverPort) throws ParseException, InvalidArgumentException, SipException
{
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
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();
@@ -130,10 +134,14 @@ public class VoIP implements SipListenerExt
lg.info("Erfolgreiches Senden der Registrierung");
}

public void sendInvitation(String sipaddresse, String proxyaddresse, int serverPort) throws ParseException, InvalidArgumentException, SipException, SdpException
public void sendInvitation(String sipaddresse, String proxyaddresse,
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); //evtl. mit Port: sip:192.168.100.11:5060
//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();
@@ -155,10 +163,9 @@ public class VoIP implements SipListenerExt
request.addHeader(content);

request.setContent(createSDPHeader(), content);
System.out.println("---Invitation Header---");
System.out.println(request);
this.sipProvider.sendRequest(request);
//lg.info("Erfolgreiches Senden der Invitation");
lg.info("Erfolgreiches Senden der Invitation");
}

@Override
@@ -203,82 +210,15 @@ public class VoIP implements SipListenerExt
else if ((Request.INVITE).equals(requestEvent.getRequest().getMethod())) // Invite von anderem Benutzer
{
FromHeader abc = (FromHeader) requestEvent.getRequest().getHeader("From");
String name = abc.getName();
view.getTxtArea().append("Werde von "+name+" angerufen\n");
view.getTxtArea().append("Werde von " + abc.getAddress() + " angerufen\n");
evtWerdeAngerufen = requestEvent;
lg.info("Hab Invitation bekommen");
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"));
responsetry.addHeader((ToHeader) requestEvent.getRequest().getHeader("To"));
responsetry.addHeader((CallIdHeader) requestEvent.getRequest().getHeader("Call-ID"));
responsetry.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq"));

SupportedHeader supp = this.headerFactory.createSupportedHeader("replace,path,timer"); //nachschauen
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE");

responsetry.addHeader(supp);
responsetry.addHeader(allow);
this.sipProvider.sendResponse(responsetry);
view.getTxtArea().append("Trying geschickt\n");
lg.info("Trying ist raus");

//Ringing Message to Server (Responste Ringing)
Response responsering = this.messageFactory.createResponse(180, requestEvent.getRequest());
responsering.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via"));
responsering.addHeader((FromHeader) requestEvent.getRequest().getHeader("From"));

ToHeader temptoring = (ToHeader) requestEvent.getRequest().getHeader("To");
String tempTag = String.valueOf(this.tag + Math.random());
temptoring.setTag(tempTag); //evtl. besseren Tag
responsering.addHeader(temptoring);

responsering.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq"));
responsering.addHeader(contactHeader);
responsering.addHeader(supp);
responsering.addHeader(allow);

AllowEventsHeader allowevent = this.headerFactory.createAllowEventsHeader("talk,hold");// für was gebraucht
responsering.addHeader(allowevent);
this.sipProvider.sendResponse(responsering);
view.getTxtArea().append("Ringing geschickt\n");

//Jetzt kommt 200 Ok SIP Header + SDP (SIP/SDP)
//Sdp Header erstellen nächster Schritt
invite = false;
System.out.println(requestEvent.getDialog());
Response okandSDP = this.messageFactory.createResponse(Response.OK, requestEvent.getRequest());
//okandSDP.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via"));
okandSDP.addHeader((FromHeader) requestEvent.getRequest().getHeader("From"));

okandSDP.addHeader(temptoring); //evtl noch Ergänzungen

okandSDP.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq"));
okandSDP.addHeader(contactHeader);
okandSDP.addHeader(supp);
okandSDP.addHeader(allow);
okandSDP.addHeader(allowevent);
ContentTypeHeader content = headerFactory.createContentTypeHeader("application", "sdp");
okandSDP.addHeader(content);
okandSDP.setContent(createSDPHeader(), content);
System.out.println(okandSDP);
this.sipProvider.sendResponse(okandSDP);
}
catch (ParseException | SipException | SdpException ex)
{
Logger.getLogger(VoIP.class.getName()).log(Level.SEVERE, null, ex);

}

}
}
else if ((Request.ACK).equals(requestEvent.getRequest().getMethod()))
{

}
}

@Override
@@ -384,11 +324,89 @@ public class VoIP implements SipListenerExt
return sessionDescription;
}

public void annehmen() //Fehlende Bedingung
{
RequestEvent requestEvent;
if ((requestEvent=evtWerdeAngerufen) != null)
{

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"));
responsetry.addHeader((ToHeader) requestEvent.getRequest().getHeader("To"));
responsetry.addHeader((CallIdHeader) requestEvent.getRequest().getHeader("Call-ID"));
responsetry.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq"));

SupportedHeader supp = this.headerFactory.createSupportedHeader("replace,path,timer"); //nachschauen
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE");

responsetry.addHeader(supp);
responsetry.addHeader(allow);
this.sipProvider.sendResponse(responsetry);
view.getTxtArea().append("Trying geschickt\n");
lg.info("Trying ist raus");

//Ringing Message to Server (Responste Ringing)
Response responsering = this.messageFactory.createResponse(180, requestEvent.getRequest());
responsering.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via"));
responsering.addHeader((FromHeader) requestEvent.getRequest().getHeader("From"));

ToHeader temptoring = (ToHeader) requestEvent.getRequest().getHeader("To");
String tempTag = String.valueOf(this.tag + Math.random());
temptoring.setTag(tempTag); //evtl. besseren Tag
responsering.addHeader(temptoring);

responsering.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq"));
responsering.addHeader(contactHeader);
responsering.addHeader(supp);
responsering.addHeader(allow);

AllowEventsHeader allowevent = this.headerFactory.createAllowEventsHeader("talk,hold");// für was gebraucht
responsering.addHeader(allowevent);
this.sipProvider.sendResponse(responsering);
view.getTxtArea().append("Ringing geschickt\n");

//Jetzt kommt 200 Ok SIP Header + SDP (SIP/SDP)
//Sdp Header erstellen nächster Schritt
invite = false;
System.out.println(requestEvent.getDialog());
Response okandSDP = this.messageFactory.createResponse(Response.OK, requestEvent.getRequest());
//okandSDP.addHeader((ViaHeader) requestEvent.getRequest().getHeader("Via"));
okandSDP.addHeader((FromHeader) requestEvent.getRequest().getHeader("From"));

okandSDP.addHeader(temptoring); //evtl noch Ergänzungen

okandSDP.addHeader((CSeqHeader) requestEvent.getRequest().getHeader("Cseq"));
okandSDP.addHeader(contactHeader);
okandSDP.addHeader(supp);
okandSDP.addHeader(allow);
okandSDP.addHeader(allowevent);
ContentTypeHeader content = headerFactory.createContentTypeHeader("application", "sdp");
okandSDP.addHeader(content);
okandSDP.setContent(createSDPHeader(), content);
System.out.println(okandSDP);
this.sipProvider.sendResponse(okandSDP);
evtWerdeAngerufen =null;
}
catch (ParseException | SipException | SdpException ex)
{
Logger.getLogger(VoIP.class.getName()).log(Level.SEVERE, null, ex);

}
}
}

//Get Methoden falls man mal die Parameter braucht
public void cancelcall()
{
}

public String getmyName()
{
return myName;

+ 3
- 3
src/phone/Start.java View File

@@ -13,8 +13,8 @@ import java.net.UnknownHostException;
import java.text.ParseException;
import model.VoIP;
/**
* Builder Class
* @author Normal
* Builder Class / Start Klasse des Programmes
* @author Jan
*/
public class Start
{
@@ -31,7 +31,7 @@ public class Start
view.getTxtServerIP().setText("192.168.100.11");
view.getTxtcallIP().setText("121");
//view.setExtendedState(view.MAXIMIZED_BOTH);
view.setSize(300, 200);
view.setSize(400, 400);
view.setTitle("TestOberfläche VoIP Phone");
view.setVisible(true);


Loading…
Cancel
Save