Ejemplo n.º 1
0
  private void propertyUpdate(Message msg) throws IOException {
    String key = (String) msg.getData().get(0);
    String newValue = (String) msg.getData().get(1);

    PreferencesModelServer.setProperty(key, newValue);

    if (this.propertyUpdateListener != null) {
      this.propertyUpdateListener.propertyUpdate(key);
    }

    broadcastMessage(new Message(OpCode.STC_PROPERTY_UPDATE_ACK, key, newValue));
  }
Ejemplo n.º 2
0
  private void showMediaFile(Message msg)
      throws MediaDoesNotExsistException, MediaListsEmptyException, PriorityDoesNotExistException {
    UUID toShow = (UUID) msg.getData().get(0);
    ServerMediaFile fileToShow = this.mediaModel.getMediaFileById(toShow);

    showMedia(fileToShow);
  }
Ejemplo n.º 3
0
  private void dequeueMediaFile(Message msg)
      throws MediaDoesNotExsistException, OutOfSyncException {
    DequeueData mediaToDequeue = (DequeueData) msg.getData().get(0);
    this.mediaModel.dequeue(mediaToDequeue.getId(), mediaToDequeue.getRow());

    broadcastMessage(new Message(OpCode.STC_DEQUEUE_MEDIAFILE_ACK, mediaToDequeue));
  }
Ejemplo n.º 4
0
  private void removePriority(Message msg) throws IOException {
    UUID prioToRemove = (UUID) msg.getData().get(0);
    this.prefsModel.removePriority(prioToRemove);
    broadcastMessage(new Message(OpCode.STC_REMOVE_PRIORITY_ACK, prioToRemove));

    this.prefsModel.serializePriorityDatabase();
  }
Ejemplo n.º 5
0
  private void removeTheme(Message msg) throws IOException {
    UUID themeToRemove = (UUID) msg.getData().get(0);
    this.prefsModel.removeTheme(themeToRemove);
    broadcastMessage(new Message(OpCode.STC_REMOVE_THEME_ACK, themeToRemove));

    this.prefsModel.serializeThemeDatabase();
  }
Ejemplo n.º 6
0
  private void addTheme(Message msg) throws IOException {
    Theme themeToAdd = (Theme) msg.getData().get(0);
    this.prefsModel.addTheme(themeToAdd);
    broadcastMessage(new Message(OpCode.STC_ADD_THEME_ACK, themeToAdd));

    this.prefsModel.serializeThemeDatabase();
  }
Ejemplo n.º 7
0
  private void addPriority(Message msg) throws IOException {
    Priority prioToAdd = (Priority) msg.getData().get(0);
    this.prefsModel.addPriority(prioToAdd);
    broadcastMessage(new Message(OpCode.STC_ADD_PRIORITY_ACK, prioToAdd));

    this.prefsModel.serializePriorityDatabase();
  }
Ejemplo n.º 8
0
  private void removeMediaFile(Message msg) throws MediaDoesNotExsistException, IOException {
    UUID toRemove = (UUID) msg.getData().get(0);
    this.mediaModel.removeMediaFile(toRemove);

    broadcastMessage(new Message(OpCode.STC_REMOVE_MEDIA_FILE_ACK, toRemove));

    this.prefsModel.serializeMediaDatabase();
  }
Ejemplo n.º 9
0
  private void editMediaFile(Message msg)
      throws MediaDoesNotExsistException, FileNotFoundException, IOException, URISyntaxException {
    ClientMediaFile editedFile = (ClientMediaFile) msg.getData().get(0);
    ServerMediaFile correlatedServerFile = this.mediaModel.getMediaFileById(editedFile.getId());
    correlatedServerFile.setName(editedFile.getName());
    correlatedServerFile.setPriority(editedFile.getPriorityID());
    broadcastMessage(
        new Message(OpCode.STC_EDIT_MEDIA_FILE_ACK, new ClientMediaFile(correlatedServerFile)));

    this.prefsModel.serializeMediaDatabase();
  }
Ejemplo n.º 10
0
  private void addLiveTickerElement(Message msg) throws IOException {
    TickerElement eltToAdd = (TickerElement) msg.getData().get(0);
    this.tickerModel.addTickerElement(eltToAdd);

    if (this.liveTickerEnabled) {
      this.serverGUI.updateLiveTickerString();
    }

    broadcastMessage(new Message(OpCode.STC_ADD_LIVE_TICKER_ELEMENT_ACK, eltToAdd));

    this.prefsModel.serializeTickerDatabase();
  }
Ejemplo n.º 11
0
  private void removeLiveTickerElement(Message msg)
      throws MediaDoesNotExsistException, IOException {
    UUID eltToRemove = (UUID) msg.getData().get(0);
    this.tickerModel.removeTickerElement(eltToRemove);

    if (this.liveTickerEnabled) {
      this.serverGUI.updateLiveTickerString();
    }

    broadcastMessage(new Message(OpCode.STC_REMOVE_LIVE_TICKER_ELEMENT_ACK, eltToRemove));

    this.prefsModel.serializeTickerDatabase();
  }
Ejemplo n.º 12
0
  private void editLiveTickerElement(Message msg) throws MediaDoesNotExsistException, IOException {
    TickerElement edited = (TickerElement) msg.getData().get(0);
    TickerElement correlatedServerFile = this.tickerModel.getElementByID(edited.getId());
    correlatedServerFile.setShow(edited.isShow());
    correlatedServerFile.setText(edited.getText());

    if (this.liveTickerEnabled) {
      this.serverGUI.updateLiveTickerString();
    }

    broadcastMessage(new Message(OpCode.STC_EDIT_LIVE_TICKER_ELEMENT_ACK, correlatedServerFile));
    this.prefsModel.serializeTickerDatabase();
  }
Ejemplo n.º 13
0
  private void loginRequest(Message msg, ChannelHandlerContext ctx) throws InterruptedException {
    LoginData login = (LoginData) msg.getData().get(0);

    if (login.getKey().equals(PreferencesModelServer.getPropertyByKey(ConstantsServer.PROP_PW))) {

      if (findUserByAlias(login.getAlias()) == null) {
        clientConnected(ctx.channel(), login.getAlias());

        ctx.writeAndFlush(new Message(OpCode.STC_CONNECTION_ACK));

        log.info("Client connected successfully. Alias: " + login.getAlias());
      } else {
        denyAccessToClient("Alias already in use.", ctx);
      }

    } else {
      denyAccessToClient("No valid login.", ctx);
    }
  }
Ejemplo n.º 14
0
 private void addThemeSlide(Message msg) throws FileNotFoundException, IOException {
   Themeslide themeslide = (Themeslide) msg.getData().get(0);
   addMediaFile(themeslide);
 }
Ejemplo n.º 15
0
 private void resetShowCount(Message msg) throws MediaDoesNotExsistException, IOException {
   UUID toReset = (UUID) msg.getData().get(0);
   this.mediaModel.resetShowCount(toReset);
   broadcastMessage(new Message(OpCode.STC_RESET_SHOW_COUNT_ACK, toReset));
 }
Ejemplo n.º 16
0
 private void addVideoFile(Message msg) throws IOException {
   VideoFile file = (VideoFile) msg.getData().get(0);
   addMediaFile(file);
 }
Ejemplo n.º 17
0
 private void clientDisconnect(Message msg, ChannelHandlerContext ctx) {
   clientDisconnected(ctx.channel(), (String) msg.getData().get(0));
 }
Ejemplo n.º 18
0
 private void addImageFile(Message msg) throws FileNotFoundException, IOException {
   ImageFile imageFile = (ImageFile) msg.getData().get(0);
   addMediaFile(imageFile);
 }
Ejemplo n.º 19
0
 private void receiveMessage(Message msg, ChannelHandlerContext ctx)
     throws MediaDoesNotExsistException, MediaListsEmptyException, UnkownMessageException,
         OutOfSyncException, FileNotFoundException, IOException, PriorityDoesNotExistException,
         InterruptedException, URISyntaxException {
   switch (msg.getOpCode()) {
     case CTS_ADD_IMAGE_FILE:
       addImageFile(msg);
       break;
     case CTS_ADD_COUNTDOWN:
       addCountdown(msg);
       break;
     case CTS_ADD_THEMESLIDE:
       addThemeSlide(msg);
       break;
     case CTS_REMOVE_MEDIA_FILE:
       removeMediaFile(msg);
       break;
     case CTS_SHOW_MEDIA_FILE:
       showMediaFile(msg);
       break;
     case CTS_EDIT_MEDIA_FILE:
       editMediaFile(msg);
       break;
     case CTS_EDIT_LIVE_TICKER_ELEMENT:
       editLiveTickerElement(msg);
       break;
     case CTS_SHOW_NEXT_MEDIA_FILE:
       showNextMediaFile();
       break;
     case CTS_QUEUE_MEDIA_FILE:
       queueMediaFile(msg);
       break;
     case CTS_ADD_LIVE_TICKER_ELEMENT:
       addLiveTickerElement(msg);
       break;
     case CTS_REMOVE_LIVE_TICKER_ELEMENT:
       removeLiveTickerElement(msg);
       break;
     case CTS_ADD_THEME:
       addTheme(msg);
       break;
     case CTS_ADD_PRIORITY:
       addPriority(msg);
       break;
     case CTS_REMOVE_THEME:
       removeTheme(msg);
       break;
     case CTS_REMOVE_PRIORITY:
       removePriority(msg);
       break;
     case CTS_ENABLE_LIVE_TICKER:
       enableLiveTicker();
       break;
     case CTS_DISABLE_LIVE_TICKER:
       disableLiveTicker();
       break;
     case CTS_ENABLE_AUTO_MODE:
       enableAutoMode();
       break;
     case CTS_DISABLE_AUTO_MODE:
       disableAutoMode();
       break;
     case CTS_ENABLE_FULLSCREEN:
       enableFullScreen();
       break;
     case CTS_DISABLE_FULLSCREEN:
       disableFullScreen();
       break;
     case CTS_DEQUEUE_MEDIAFILE:
       dequeueMediaFile(msg);
       break;
     case CTS_REQUEST_FULL_SYNC:
       fullSyncRequested(msg, ctx);
       break;
     case CTS_RESET_SHOW_COUNT:
       resetShowCount(msg);
       break;
     case CTS_ADD_VIDEO_FILE:
       addVideoFile(msg);
       break;
     case CTS_REQUEST_SERVER_SHUTDOWN:
       serverShutdownRequested();
       break;
     case CTS_HEARTBEAT_ACK:
       hearbeatack(ctx);
       break;
     case CTS_PROPERTY_UPDATE:
       propertyUpdate(msg);
       break;
     case CTS_LOGIN_REQUEST:
       loginRequest(msg, ctx);
       break;
     case CTS_DISCONNECT:
       clientDisconnect(msg, ctx);
       break;
     default:
       unkownMessageReceived(msg);
       break;
   }
 }
Ejemplo n.º 20
0
  private void queueMediaFile(Message msg) throws MediaDoesNotExsistException {
    UUID toQueue = (UUID) msg.getData().get(0);
    this.mediaModel.queue(toQueue);

    broadcastMessage(new Message(OpCode.STC_QUEUE_MEDIA_FILE_ACK, toQueue));
  }
Ejemplo n.º 21
0
 private void unkownMessageReceived(Message msg) throws UnkownMessageException {
   throw new UnkownMessageException(
       "A unkown message was received. Debug information: " + msg.toString());
 }
Ejemplo n.º 22
0
 private void addCountdown(Message msg) throws FileNotFoundException, IOException {
   addMediaFile((ServerMediaFile) msg.getData().get(0));
 }