Added chat mute and user (de)activation actions to the Mage server console.

This commit is contained in:
LevelX2 2016-10-05 00:59:51 +02:00
parent 7c4b40073c
commit c46f75ac28
18 changed files with 511 additions and 213 deletions

View file

@ -215,6 +215,10 @@ public interface MageServer {
void muteUser(String sessionId, String userName, long durationMinutes) throws MageException;
void lockUser(String sessionId, String userName, long durationMinutes) throws MageException;
void toggleActivation(String sessionId, String userName) throws MageException;
void removeTable(String sessionId, UUID tableId) throws MageException;
void sendBroadcastMessage(String sessionId, String message) throws MageException;

View file

@ -1440,6 +1440,36 @@ public class SessionImpl implements Session {
return false;
}
@Override
public boolean toggleActivation(String userName) {
try {
if (isConnected()) {
server.toggleActivation(sessionId, userName);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
@Override
public boolean lockUser(String userName, long durationMinute) {
try {
if (isConnected()) {
server.lockUser(sessionId, userName, durationMinute);
return true;
}
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
private void handleThrowable(Throwable t) {
logger.fatal("Communication error", t);
// Probably this can cause hanging the client under certain circumstances as the disconnect method is synchronized

View file

@ -58,5 +58,9 @@ public interface Connect {
boolean muteUserChat(String userName, long durationMinute);
boolean toggleActivation(String userName);
boolean lockUser(String userName, long durationMinute);
String getSessionId();
}

View file

@ -43,14 +43,16 @@ public class UserView implements Serializable {
private final Date timeConnected;
private final String gameInfo;
private final String userState;
private final Date muteChatUntil;
public UserView(String userName, String host, String sessionId, Date timeConnected, String gameInfo, String userState) {
public UserView(String userName, String host, String sessionId, Date timeConnected, String gameInfo, String userState, Date muteChatUntil) {
this.userName = userName;
this.host = host;
this.sessionId = sessionId;
this.timeConnected = timeConnected;
this.gameInfo = gameInfo;
this.userState = userState;
this.muteChatUntil = muteChatUntil;
}
public String getUserName() {
@ -77,4 +79,8 @@ public class UserView implements Serializable {
return userState;
}
public Date getMuteChatUntil() {
return muteChatUntil;
}
}