mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 22:12:03 -08:00
Added chat mute and user (de)activation actions to the Mage server console.
This commit is contained in:
parent
7c4b40073c
commit
c46f75ac28
18 changed files with 511 additions and 213 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue