mirror of
https://github.com/correl/mage.git
synced 2024-12-01 03:00:09 +00:00
Server: improved ping info (added last activity time)
This commit is contained in:
parent
2079065af3
commit
f4a0c70cf3
3 changed files with 22 additions and 16 deletions
|
@ -1,12 +1,5 @@
|
|||
package mage.remote;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.*;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.cards.repository.CardInfo;
|
||||
|
@ -35,6 +28,14 @@ import org.jboss.remoting.transport.bisocket.Bisocket;
|
|||
import org.jboss.remoting.transport.socket.SocketWrapper;
|
||||
import org.jboss.remoting.transporter.TransporterClient;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||
*/
|
||||
|
@ -1676,7 +1677,7 @@ public class SessionImpl implements Session {
|
|||
sum += time;
|
||||
}
|
||||
milliSeconds = TimeUnit.MILLISECONDS.convert(sum / pingTime.size(), TimeUnit.NANOSECONDS);
|
||||
pingInfo = lastPing + " (Av: " + (milliSeconds > 0 ? milliSeconds + "ms" : "<1ms") + ')';
|
||||
pingInfo = lastPing + " (avg: " + (milliSeconds > 0 ? milliSeconds + "ms" : "<1ms") + ')';
|
||||
}
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
|
|
|
@ -193,10 +193,11 @@ public class User {
|
|||
}
|
||||
|
||||
public String getDisconnectDuration() {
|
||||
long secondsDisconnected = getSecondsDisconnected();
|
||||
int minutes = (int) secondsDisconnected / 60;
|
||||
int seconds = (int) secondsDisconnected % 60;
|
||||
return Integer.toString(minutes) + ':' + (seconds > 9 ? seconds : '0' + Integer.toString(seconds));
|
||||
//long secondsDisconnected = getSecondsDisconnected();
|
||||
//int minutes = (int) secondsDisconnected / 60;
|
||||
//int seconds = (int) secondsDisconnected % 60;
|
||||
//return Integer.toString(minutes) + ':' + (seconds > 9 ? seconds : '0' + Integer.toString(seconds));
|
||||
return getSecondsDisconnected() + " secs";
|
||||
}
|
||||
|
||||
public long getSecondsDisconnected() {
|
||||
|
@ -218,7 +219,11 @@ public class User {
|
|||
hours = minutes / 60;
|
||||
minutes = minutes - (hours * 60);
|
||||
}
|
||||
return hours + ":" + (minutes > 9 ? Integer.toString(minutes) : '0' + Integer.toString(minutes));
|
||||
String connTime = hours + ":" + (minutes > 9 ? Integer.toString(minutes) : '0' + Integer.toString(minutes));
|
||||
|
||||
int lastSecs = (int) SystemUtil.getDateDiff(lastActivity, new Date(), TimeUnit.SECONDS);
|
||||
|
||||
return " (online: " + connTime + "; seen: " + lastSecs + " sec ago)";
|
||||
}
|
||||
|
||||
public void fireCallback(final ClientCallback call) {
|
||||
|
|
|
@ -1192,7 +1192,7 @@ public class GameController implements GameCallback {
|
|||
List<String> usersInfo = new ArrayList<>();
|
||||
for (Map.Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
Optional<User> user = UserManager.instance.getUser(entry.getKey());
|
||||
user.ifPresent(u -> usersInfo.add(u.getName() + ": " + u.getPingInfo()));
|
||||
user.ifPresent(u -> usersInfo.add("* " + u.getName() + ": " + u.getPingInfo()));
|
||||
}
|
||||
Collections.sort(usersInfo);
|
||||
usersInfo.add(0, "Players ping:");
|
||||
|
@ -1200,7 +1200,7 @@ public class GameController implements GameCallback {
|
|||
List<String> watchersinfo = new ArrayList<>();
|
||||
for (Map.Entry<UUID, GameSessionWatcher> entry : watchers.entrySet()) {
|
||||
Optional<User> user = UserManager.instance.getUser(entry.getValue().userId);
|
||||
user.ifPresent(u -> watchersinfo.add(u.getName() + ": " + u.getPingInfo()));
|
||||
user.ifPresent(u -> watchersinfo.add("* " + u.getName() + ": " + u.getPingInfo()));
|
||||
}
|
||||
Collections.sort(watchersinfo);
|
||||
if (watchersinfo.size() > 0) {
|
||||
|
|
Loading…
Reference in a new issue