Exemplo n.º 1
0
  public void clientDisconnected(Channel chan, String alias) {

    this.allClients.remove(chan);
    ConnectedUser user = findUserByChan(chan);
    this.connectedUsers.remove(user);
    log.info("Client disconnected. Alias: " + user.getAlias());
  }
Exemplo n.º 2
0
 public ConnectedUser findUserByAlias(String alias) {
   for (ConnectedUser user : this.connectedUsers) {
     if (user.getAlias().equals(alias)) {
       return user;
     }
   }
   return null;
 }
Exemplo n.º 3
0
 public ConnectedUser findUserByChan(Channel chan) {
   for (ConnectedUser user : this.connectedUsers) {
     InetSocketAddress argChanAddr = ((InetSocketAddress) chan.remoteAddress());
     InetSocketAddress searchChanAddr = ((InetSocketAddress) user.getChannel().remoteAddress());
     if (searchChanAddr.getAddress().equals(argChanAddr.getAddress())
         && searchChanAddr.getPort() == argChanAddr.getPort()) {
       return user;
     }
   }
   return null;
 }
Exemplo n.º 4
0
    // TODO timeout handling improvement. use nettys build in handlers which
    // also take sent traffic into account
    @Override
    public void run(Timeout timeout) throws Exception {

      ArrayList<ConnectedUser> timedOuts = new ArrayList<ConnectedUser>();

      MessageProxyServer.this.timeoutChecker.newTimeout(
          new TimeoutTimerTask(), MessageProxyServer.this.timeoutInSeconds, TimeUnit.SECONDS);
      for (ConnectedUser user : MessageProxyServer.this.connectedUsers) {
        if (!user.isAlive()) {
          timedOuts.add(user);
        }
        user.setAlive(false);
      }
      for (ConnectedUser user : timedOuts) {
        clientTimedOut(user.getChannel());
      }
      broadcastMessage(new Message(OpCode.STC_HEARTBEAT_REQUEST));
    }
Exemplo n.º 5
0
 public void clientTimedOut(Channel chan) {
   this.allClients.remove(chan);
   ConnectedUser user = findUserByChan(chan);
   log.info("Client timed out. Alias: " + user.getAlias());
   this.connectedUsers.remove(user);
 }