mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-25 07:59:44 +00: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
1 changed files with 23 additions and 24 deletions
|
@ -65,7 +65,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||||
}
|
}
|
||||||
catch (XMPPException ex)
|
catch (XMPPException ex)
|
||||||
{
|
{
|
||||||
disableChat(address, ex);
|
disableChat(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,9 +73,11 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||||
@Override
|
@Override
|
||||||
public void processMessage(final Chat chat, final Message msg)
|
public void processMessage(final Chat chat, final Message msg)
|
||||||
{
|
{
|
||||||
final String message = msg.getBody();
|
// Normally we should log the error message
|
||||||
if (message.length() > 0)
|
// 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))
|
switch (message.charAt(0))
|
||||||
{
|
{
|
||||||
case '@':
|
case '@':
|
||||||
|
@ -199,10 +201,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// Ignore all exception and just print them to the console
|
// Ignore all exceptions
|
||||||
// Otherwise we create a loop.
|
// 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
|
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)
|
for (Player p : matches)
|
||||||
{
|
{
|
||||||
p.sendMessage(from + p.getDisplayName() + "] " + message);
|
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);
|
final Chat chat = chats.get(address);
|
||||||
if (chat != null)
|
if (chat != null)
|
||||||
{
|
{
|
||||||
chat.removeMessageListener(this);
|
chat.removeMessageListener(this);
|
||||||
chats.remove(address);
|
chats.remove(address);
|
||||||
LOGGER.log(Level.WARNING, "Failed to send xmpp message.", exception);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue