Javadoc updates and catched exception when sending msg to disconnected
client
This commit is contained in:
parent
b0f362fd0b
commit
71d5a698e5
@ -15,18 +15,35 @@ public class LoginManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user in
|
||||
* @param address User to login
|
||||
*/
|
||||
public void logIn(InetSocketAddress address) {
|
||||
loggedInUsers.add(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user out
|
||||
* @param address User to logout
|
||||
*/
|
||||
public void logOut(InetSocketAddress address) {
|
||||
loggedInUsers.remove(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is logged in
|
||||
* @param address User to check
|
||||
* @return true if user is logged in, false otherwise
|
||||
*/
|
||||
public boolean isLoggedIn(InetSocketAddress address) {
|
||||
return loggedInUsers.contains(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the full logged-in user list
|
||||
* @return list of logged in users
|
||||
*/
|
||||
public ArrayList<InetSocketAddress> getLoggedInUsers() {
|
||||
return loggedInUsers;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.exceptions.WebsocketNotConnectedException;
|
||||
import org.java_websocket.handshake.ClientHandshake;
|
||||
import org.java_websocket.server.WebSocketServer;
|
||||
|
||||
@ -106,7 +107,12 @@ public class WSServer extends WebSocketServer {
|
||||
* @param content JSONOutput object
|
||||
*/
|
||||
public void sendToClient(WebSocket conn, JSONOutput content) {
|
||||
conn.send(content.toJSON());
|
||||
try {
|
||||
conn.send(content.toJSON());
|
||||
}catch(WebsocketNotConnectedException e) {
|
||||
Bukkit.getLogger().warning("Tried to send message to a disconnected client.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user