You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandController.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package controller;
  7. import gui.Hauptfenster;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. import java.text.ParseException;
  11. import java.util.logging.Level;
  12. import java.util.logging.Logger;
  13. import javax.sdp.SdpException;
  14. import javax.sip.InvalidArgumentException;
  15. import javax.sip.SipException;
  16. import logger.OhmLogger;
  17. import model.VoIP;
  18. /**
  19. *
  20. * @author Normal
  21. */
  22. public class CommandController implements ActionListener
  23. {
  24. private static final Logger lc = OhmLogger.getLogger();
  25. private VoIP model;
  26. private Hauptfenster view;
  27. public CommandController(VoIP model, Hauptfenster view)
  28. {
  29. this.model = model;
  30. this.view = view;
  31. }
  32. public void registerEvents()
  33. {
  34. view.getBtn1().addActionListener(this);
  35. view.getBtn2().addActionListener(this);
  36. }
  37. @Override
  38. public void actionPerformed(ActionEvent e)
  39. {
  40. Object key = e.getSource();
  41. if (key.equals(view.getBtn1()))
  42. {
  43. lc.info("Register Butten geklickt");
  44. try
  45. {
  46. model.sendRegister("123123", 1);
  47. }
  48. catch (ParseException|InvalidArgumentException|SipException ex)
  49. {
  50. lc.getLogger(CommandController.class.getName()).log(Level.SEVERE, null, ex);
  51. }
  52. }
  53. if(key.equals(view.getBtn2()))
  54. {
  55. try {
  56. lc.info("Invite Button geklickt");
  57. model.sendInvitation("23", 2);
  58. }
  59. catch (ParseException|InvalidArgumentException|SdpException|SipException ex) {
  60. lc.getLogger(CommandController.class.getName()).log(Level.SEVERE, null, ex);
  61. }
  62. }
  63. }
  64. }