Package net.cis.server.main.listener

Source Code of net.cis.server.main.listener.ServerConnectionListener

package net.cis.server.main.listener;

import java.util.Map;

import net.cis.server.backend.model.ClientState;

import com.jme3.network.ConnectionListener;
import com.jme3.network.HostedConnection;
import com.jme3.network.Server;

// TODO: offene Connections sollten nach einem timeout gekillt werden, wenn sie nicht genutzt/authentifiziert sind.
public class ServerConnectionListener implements ConnectionListener {
  private final Map<Integer, ClientState> clientMap;

  public ServerConnectionListener(Map<Integer, ClientState> clientMap) {
    this.clientMap = clientMap;
  }

  @Override
  public void connectionAdded(Server server, HostedConnection conn) {
    int id = conn.getId();
    clientMap.put(id, new ClientState(conn));
  }

  @Override
  public void connectionRemoved(Server server, HostedConnection conn) {
    clientMap.remove(conn.getId());
  }
}
TOP

Related Classes of net.cis.server.main.listener.ServerConnectionListener

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.