Skip to content

Commit

Permalink
v0.4.4 svr console
Browse files Browse the repository at this point in the history
  • Loading branch information
Immueggpain authored and Immueggpain committed Dec 5, 2019
1 parent 9f544bc commit f4c8d67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.immueggpain</groupId>
<artifactId>bettermultiplayer</artifactId>
<version>0.4.3</version>
<version>0.4.4</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private static class Player {
/** time of the last packet received from this player */
public long t;
public InetSocketAddress saddr;
public long pktCount = 0;
}

private HashMap<InetSocketAddress, Player> activePlayers = new HashMap<>();
Expand Down Expand Up @@ -67,15 +68,18 @@ private void remove_expired_player_thread() {
while (true) {
synchronized (activePlayers) {
long now = System.currentTimeMillis();
System.out.println("==player check==" + now);
for (Iterator<Entry<InetSocketAddress, Player>> iterator = activePlayers.entrySet().iterator(); iterator
.hasNext();) {
Entry<InetSocketAddress, Player> entry = iterator.next();
long last = entry.getValue().t;
Player playerInfo = entry.getValue();
long last = playerInfo.t;
if (now - last > 60000) {
System.out.println("dead player: " + entry.getValue().saddr);
System.out.println(String.format("dead player: %s, %d", playerInfo.saddr, playerInfo.pktCount));
iterator.remove();
} else {
System.out.println("active player: " + entry.getValue().saddr);
System.out
.println(String.format("active player: %s, %d", playerInfo.saddr, playerInfo.pktCount));
}
}
}
Expand All @@ -92,6 +96,7 @@ private void updatePlayerInfo(InetSocketAddress saddr, long t) {
activePlayers.put(saddr, player);
}
player.t = t;
player.pktCount++;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
version = Launcher.VERSTR, subcommands = { HelpCommand.class, BMPUDPHub.class, BMPPeer.class })
public class Launcher implements Callable<Void> {

public static final String VERSTR = "0.4.3";
public static final String VERSTR = "0.4.4";
public static final int LOCAL_PORT = 2233;
public static final int LOCAL_OVPN_PORT = 1194;

Expand Down

0 comments on commit f4c8d67

Please sign in to comment.