예제 #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));
  }
예제 #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);
  }
예제 #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));
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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();
  }
예제 #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);
    }
  }
예제 #14
0
 private void addThemeSlide(Message msg) throws FileNotFoundException, IOException {
   Themeslide themeslide = (Themeslide) msg.getData().get(0);
   addMediaFile(themeslide);
 }
예제 #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));
 }
예제 #16
0
 private void addVideoFile(Message msg) throws IOException {
   VideoFile file = (VideoFile) msg.getData().get(0);
   addMediaFile(file);
 }
예제 #17
0
 private void clientDisconnect(Message msg, ChannelHandlerContext ctx) {
   clientDisconnected(ctx.channel(), (String) msg.getData().get(0));
 }
예제 #18
0
 private void addImageFile(Message msg) throws FileNotFoundException, IOException {
   ImageFile imageFile = (ImageFile) msg.getData().get(0);
   addMediaFile(imageFile);
 }
예제 #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;
   }
 }
예제 #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));
  }
예제 #21
0
 private void unkownMessageReceived(Message msg) throws UnkownMessageException {
   throw new UnkownMessageException(
       "A unkown message was received. Debug information: " + msg.toString());
 }
예제 #22
0
 private void addCountdown(Message msg) throws FileNotFoundException, IOException {
   addMediaFile((ServerMediaFile) msg.getData().get(0));
 }