mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-03-11 06:09:29 +01:00
Fixes for XMPP: Prevent loops on errors
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1577 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
991a5cb24c
commit
5a47d18a9b
@ -65,7 +65,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
}
|
||||
catch (XMPPException ex)
|
||||
{
|
||||
disableChat(address, ex);
|
||||
disableChat(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,9 +73,11 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
@Override
|
||||
public void processMessage(final Chat chat, final Message msg)
|
||||
{
|
||||
final String message = msg.getBody();
|
||||
if (message.length() > 0)
|
||||
// Normally we should log the error message
|
||||
// But we would create a loop if the connection to a log-user fails.
|
||||
if (msg.getType() != Message.Type.error && msg.getBody().length() > 0)
|
||||
{
|
||||
final String message = msg.getBody();
|
||||
switch (message.charAt(0))
|
||||
{
|
||||
case '@':
|
||||
@ -199,10 +201,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Ignore all exception and just print them to the console
|
||||
// Ignore all exceptions
|
||||
// Otherwise we create a loop.
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
}
|
||||
else
|
||||
{
|
||||
final String from = "[X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
|
||||
final String from = "[X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
|
||||
for (Player p : matches)
|
||||
{
|
||||
p.sendMessage(from + p.getDisplayName() + "] " + message);
|
||||
@ -279,14 +279,13 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||
}
|
||||
}
|
||||
|
||||
private void disableChat(final String address, final XMPPException exception)
|
||||
private void disableChat(final String address)
|
||||
{
|
||||
final Chat chat = chats.get(address);
|
||||
if (chat != null)
|
||||
{
|
||||
chat.removeMessageListener(this);
|
||||
chats.remove(address);
|
||||
LOGGER.log(Level.WARNING, "Failed to send xmpp message.", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user