Пример #1
0
  public MessageProxyServer(Server server, ServerGUI serverGUI) {

    this.allClients = new DefaultChannelGroup("beamer-clients", new NioEventLoopGroup().next());
    this.mediaModel = new MediaModelServer(this);
    this.tickerModel = new TickerModelServer(this);
    this.prefsModel = new PreferencesModelServer(this);
    this.prefsModel.deserializeAll();
    this.serverGUI = serverGUI;
    this.server = server;
    this.connectedUsers = new ArrayList<ConnectedUser>();
    this.timeoutChecker = new HashedWheelTimer();

    try {
      this.timeoutInSeconds =
          Integer.parseInt(
              PreferencesModelServer.getPropertyByKey(ConstantsServer.PROP_HEARTBEAT_INTERVALL));
    } catch (NumberFormatException e) {
      try {
        this.timeoutInSeconds = Integer.parseInt(ConstantsServer.DEFAULT_HEARTBEAT_INTERVALL);
      } catch (NumberFormatException e1) {
        this.timeoutInSeconds = 30;
      }
      log.log(Level.WARNING, "Read timeout is no number.", e);
    }

    // TODO hearbeat mechanism is diasbled, but is actually also bullshit
    // this.timeoutChecker.newTimeout(new TimeoutTimerTask(),
    // this.timeoutInSeconds, TimeUnit.SECONDS);

  }
Пример #2
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));
  }
Пример #3
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);
    }
  }
Пример #4
0
  /*
   * !!!!!!!!!!!!!!! !!!!!! Test with notebook as server (esp. video things
   * and fullscreen switches (preferred using tv as monitor like the beamer))
   * !!!!!!!!!!!!!!!
   *
   * DONE 1 Add proper serialization (properties are good, but serialize the
   * media and ticker elts and so on too) DONE 2 Check all TODOS DONE 3 next
   * exception handling DONE 4 reconnecting with a timer -> see todo reconnect
   * in clientmsghandler
   *
   * DONE add handling for further prefs like changing fonts and colors of
   * live ticker
   *
   * DONE Use Command line lib like: http://jewelcli.lexicalscope.com
   * http://pholser.github.io/jopt-simple/
   *
   * Use Installer lib like IzPack
   *
   * DONE pimp the live ticker a little slightly transparent overlay or
   * something like that next pimp server gui (Effects and so on)
   *
   * Advanced/Alternative themeslide creator using templates or something like
   * that
   *
   * check for already running server instances, and esp. get a port from the
   * os not fixed (scanning the network for the server is required then)
   *
   * pimp the client gui -> resizable areas, event log, loading dialogs during
   * network operations
   *
   * next check all the image to imageicon conversions and choose best for
   * performance and RAM usage
   *
   * show once funktion z.b. für countdown oder videos
   *
   * next proper login handling (also to see which user did what and when) and
   * maybe the possibility to send messages or notes or something like that
   */
  private void fullSyncRequested(Message msg, ChannelHandlerContext ctx)
      throws FileNotFoundException, IOException {

    HashMap<UUID, ServerMediaFile> allMedia = this.mediaModel.getAllMediaFiles();
    LinkedList<UUID> customQueue = this.mediaModel.getMediaPrivateQueue();
    HashMap<UUID, TickerElement> tickerElements = this.tickerModel.getElements();
    HashMap<UUID, Theme> themes = this.prefsModel.getThemes();
    HashMap<UUID, Priority> priorities = this.prefsModel.getPrios();

    ctx.write(new Message(OpCode.STC_FULL_SYNC_START));

    for (String k : PreferencesModelServer.getProps().stringPropertyNames()) {
      ctx.write(
          new Message(
              OpCode.STC_PROPERTY_UPDATE_ACK, k, PreferencesModelServer.getProps().getProperty(k)));
    }

    ctx.flush();

    for (UUID id : priorities.keySet()) {
      ctx.write(new Message(OpCode.STC_ADD_PRIORITY_ACK, priorities.get(id)));
    }

    ctx.flush();

    for (UUID id : themes.keySet()) {
      ctx.write(new Message(OpCode.STC_ADD_THEME_ACK, themes.get(id)));
    }

    ctx.flush();

    for (UUID id : allMedia.keySet()) {
      ctx.write(new Message(OpCode.STC_ADD_MEDIA_FILE_ACK, new ClientMediaFile(allMedia.get(id))));
    }

    ctx.flush();

    for (UUID id : customQueue) {
      ctx.write(new Message(OpCode.STC_QUEUE_MEDIA_FILE_ACK, id));
    }

    for (UUID id : tickerElements.keySet()) {
      ctx.write(new Message(OpCode.STC_ADD_LIVE_TICKER_ELEMENT_ACK, tickerElements.get(id)));
    }

    if (this.automodeEnabled) {
      ctx.write(new Message(OpCode.STC_ENABLE_AUTO_MODE_ACK));
    }

    if (this.liveTickerEnabled) {
      ctx.write(new Message(OpCode.STC_ENABLE_LIVE_TICKER_ACK));
    }

    if (this.fullscreenEnabled) {
      ctx.write(new Message(OpCode.STC_ENABLE_FULLSCREEN_ACK));
    }

    ctx.writeAndFlush(new Message(OpCode.STC_ALL_FONTS, (Object) ConstantsServer.FONT_FAMILIES));

    ctx.writeAndFlush(new Message(OpCode.STC_FULL_SYNC_STOP));
  }