Zeichnen ergänzt aber noch nicht übertragen

This commit is contained in:
Normal 2019-06-15 10:13:03 +02:00
parent 45600d2365
commit 77657a69f5
4 changed files with 20 additions and 15 deletions

View File

@ -36,17 +36,15 @@ public class CommandInvite implements CommandInterface
public void execute() public void execute()
{ {
try try
{ view.getTxtArea().append("Einladung an " + view.getTxtServerIP().getText() + " gesendet\n"); { view.getTxtArea().append("Einladung an " + view.getTxtcallIP().getText() + " gesendet\n");
model.sendInvitation(view.getTxtcallIP().getText(), 5078); model.sendInvitation(view.getTxtcallIP().getText(), 5078);
} }
catch (ParseException|InvalidArgumentException|SdpException|SipException ex) catch (ParseException|InvalidArgumentException|SdpException|SipException ex)
{ {
view.getTxtArea().append("Einladung fehlgeschlagen"); view.getTxtArea().append("Einladung fehlgeschlagen\n");
lginvite.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex); lginvite.getLogger(CommandInvite.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
@Override @Override
public void undo() public void undo()
{ {

View File

@ -37,12 +37,13 @@ public class CommandRegister implements CommandInterface
try try
{ {
view.getTxtArea().append("Registrierung an " + view.getTxtServerIP().getText() + " gesendet\n"); view.getTxtArea().append("Registrierung an " + view.getTxtServerIP().getText() + " gesendet\n");
System.out.println("Test: "+ view.getTxtServerIP().getText());
model.sendRegister(view.getTxtServerIP().getText(), 5078); model.sendRegister(view.getTxtServerIP().getText(), 5078);
} }
catch (ParseException|InvalidArgumentException|SipException ex) catch (ParseException|InvalidArgumentException|SipException ex)
{ {
view.getTxtArea().append("Registrierung fehlgeschlagen"); view.getTxtArea().append("Registrierung fehlgeschlagen\n");
lgregister.getLogger(CommandRegister.class.getName()).log(Level.SEVERE, null, ex); lgregister.getLogger(CommandRegister.class.getName()).log(Level.SEVERE, null, ex);
} }
} }

View File

@ -70,7 +70,7 @@ public class VoIP implements SipListenerExt
{ {
//wird an sich erstmal nicht gebraucht aber später sinnvoll um eigene Daten zu initialisieren //wird an sich erstmal nicht gebraucht aber später sinnvoll um eigene Daten zu initialisieren
String abc = InetAddress.getLocalHost().getHostAddress(); String abc = InetAddress.getLocalHost().getHostAddress();
/*
this.myIPAddress = InetAddress.getLocalHost().getHostAddress(); this.myIPAddress = InetAddress.getLocalHost().getHostAddress();
this.sipFactory = SipFactory.getInstance(); this.sipFactory = SipFactory.getInstance();
@ -78,7 +78,7 @@ public class VoIP implements SipListenerExt
this.properties = new Properties(); this.properties = new Properties();
this.properties.setProperty("javax.sip.STACK_NAME", "stack"); this.properties.setProperty("javax.sip.STACK_NAME", "stack");
this.sipStack = this.sipFactory.createSipStack(this.properties); this.sipStack = this.sipFactory.createSipStack(this.properties);
this.messageFactory = this.sipFactory.createMessageFactory(); this.messageFactory = this.sipFactory.createMessageFactory();
this.headerFactory = this.sipFactory.createHeaderFactory(); this.headerFactory = this.sipFactory.createHeaderFactory();
this.addressFactory = this.sipFactory.createAddressFactory(); this.addressFactory = this.sipFactory.createAddressFactory();
this.listeningPoint = this.sipStack.createListeningPoint(this.myIPAddress, this.myPort, this.protocolTyp); this.listeningPoint = this.sipStack.createListeningPoint(this.myIPAddress, this.myPort, this.protocolTyp);
@ -86,6 +86,7 @@ public class VoIP implements SipListenerExt
this.sipProvider.addSipListener(this); 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.contactHeader = this.headerFactory.createContactHeader(contactAddress); this.contactHeader = this.headerFactory.createContactHeader(contactAddress);
*/
} }
catch (Exception e) catch (Exception e)
{ {
@ -103,8 +104,12 @@ public class VoIP implements SipListenerExt
public void sendRegister(String serverIP, int serverPort) throws ParseException, InvalidArgumentException, SipException public void sendRegister(String serverIP, int serverPort) throws ParseException, InvalidArgumentException, SipException
{ {
System.out.println("Test");
System.out.println(serverIP);
lg.info("Vorbereiten des Registrierungs Headers"); lg.info("Vorbereiten des Registrierungs Headers");
Address addressto = this.addressFactory.createAddress("sip:192.168.100.11"); //evtl. mit Port: sip:192.168.100.11:5060 //Address addressto = this.addressFactory.createAddress("sip:"+serverIP); //evtl. mit Port: sip:192.168.100.11:5060
Address addressto = this.addressFactory.createAddress("sip:192.168.100.11");
System.out.println("Warum" + addressto);
ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag
URI requestURI = addressto.getURI(); URI requestURI = addressto.getURI();
CallIdHeader callId = this.sipProvider.getNewCallId(); CallIdHeader callId = this.sipProvider.getNewCallId();
@ -121,12 +126,11 @@ public class VoIP implements SipListenerExt
request.addHeader(allow); request.addHeader(allow);
request.addHeader(expire); request.addHeader(expire);
this.sipProvider.sendRequest(request); this.sipProvider.sendRequest(request);
view.getTxtArea().append("Erfolgreiche Registierung\n");
lg.info("Erfolgreiches Senden der Registrierung"); lg.info("Erfolgreiches Senden der Registrierung");
} }
public void sendInvitation(String sipaddresse, int serverPort)throws ParseException, InvalidArgumentException, SipException, SdpException public void sendInvitation(String sipaddresse, int serverPort)throws ParseException, InvalidArgumentException, SipException, SdpException
{ {
Address addressto = this.addressFactory.createAddress(sipaddresse); //evtl. mit Port: sip:192.168.100.11:5060 Address addressto = this.addressFactory.createAddress("sip:"+sipaddresse); //evtl. mit Port: sip:192.168.100.11:5060
ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag ToHeader to = this.headerFactory.createToHeader(addressto, null); // Integer.toString(tag) address + tag
URI requestURI = addressto.getURI(); URI requestURI = addressto.getURI();
CallIdHeader callId = this.sipProvider.getNewCallId(); CallIdHeader callId = this.sipProvider.getNewCallId();
@ -138,7 +142,7 @@ public class VoIP implements SipListenerExt
MaxForwardsHeader maxForwards = this.headerFactory.createMaxForwardsHeader(70); MaxForwardsHeader maxForwards = this.headerFactory.createMaxForwardsHeader(70);
AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE"); AllowHeader allow = this.headerFactory.createAllowHeader("NOTIFY,INVITE,ACK,CANCEL,BYE,REFER,INFO,OPTIONS,MESSAGE");
ExpiresHeader expire = this.headerFactory.createExpiresHeader(3600); //int value ExpiresHeader expire = this.headerFactory.createExpiresHeader(3600); //int value
Request request = this.messageFactory.createRequest(requestURI, "REGISTER", callId, cSeq, from, to, via, maxForwards); Request request = this.messageFactory.createRequest(requestURI, "INVITE", callId, cSeq, from, to, via, maxForwards);
request.addHeader(contactHeader); request.addHeader(contactHeader);
request.addHeader(allow); request.addHeader(allow);
request.addHeader(expire); request.addHeader(expire);
@ -193,7 +197,7 @@ public class VoIP implements SipListenerExt
//Aktive Kommunikation //Aktive Kommunikation
else if ((Request.INVITE).equals(requestEvent.getRequest().getMethod())) // Invite von anderem Benutzer else if ((Request.INVITE).equals(requestEvent.getRequest().getMethod())) // Invite von anderem Benutzer
{ {
view.getTxtArea().append("Werde von xxx angerufen"); view.getTxtArea().append("Werde von xxx angerufen\n");
lg.info("Hab Invitation bekommen"); lg.info("Hab Invitation bekommen");
try try
{ {
@ -213,6 +217,7 @@ public class VoIP implements SipListenerExt
responsetry.addHeader(supp); responsetry.addHeader(supp);
responsetry.addHeader(allow); responsetry.addHeader(allow);
this.sipProvider.sendResponse(responsetry); this.sipProvider.sendResponse(responsetry);
view.getTxtArea().append("Trying geschickt");
lg.info("Trying ist raus"); lg.info("Trying ist raus");
//Ringing Message to Server (Responste Ringing) //Ringing Message to Server (Responste Ringing)
@ -233,9 +238,8 @@ public class VoIP implements SipListenerExt
AllowEventsHeader allowevent = this.headerFactory.createAllowEventsHeader("talk,hold");// für was gebraucht AllowEventsHeader allowevent = this.headerFactory.createAllowEventsHeader("talk,hold");// für was gebraucht
responsering.addHeader(allowevent); responsering.addHeader(allowevent);
this.sipProvider.sendResponse(responsering); this.sipProvider.sendResponse(responsering);
System.out.println("Response ist raus"); view.getTxtArea().append("Ringing geschickt");
System.out.println("Erstelle 200 Ok + SDP Header(contentHeader)");
//Jetzt kommt 200 Ok SIP Header + SDP (SIP/SDP) //Jetzt kommt 200 Ok SIP Header + SDP (SIP/SDP)
//Sdp Header erstellen nächster Schritt //Sdp Header erstellen nächster Schritt
System.out.println(requestEvent.getDialog()); System.out.println(requestEvent.getDialog());
@ -319,6 +323,7 @@ public class VoIP implements SipListenerExt
request.addHeader(expire); request.addHeader(expire);
request.addHeader(auth); request.addHeader(auth);
this.sipProvider.sendRequest(request); this.sipProvider.sendRequest(request);
view.getTxtArea().append("Erfolgreich registriert");
} }
catch (ParseException | SipException | InvalidArgumentException ex) catch (ParseException | SipException | InvalidArgumentException ex)
{ {

View File

@ -30,7 +30,8 @@ public class Start
view.getLblmyIP().setText(InetAddress.getLocalHost().getHostAddress()); view.getLblmyIP().setText(InetAddress.getLocalHost().getHostAddress());
view.getTxtServerIP().setText("192.168.100.11"); view.getTxtServerIP().setText("192.168.100.11");
view.getTxtcallIP().setText("192.168.100.xxx"); view.getTxtcallIP().setText("192.168.100.xxx");
view.setExtendedState(view.MAXIMIZED_BOTH); //view.setExtendedState(view.MAXIMIZED_BOTH);
view.setSize(300, 200);
view.setTitle("TestOberfläche VoIP Phone"); view.setTitle("TestOberfläche VoIP Phone");
view.setVisible(true); view.setVisible(true);