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); }
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); } }