party: send join on reconnect
If the server expires the membership before the client in the party reconnects, it will falsely assume it is in a party when it isn't. Additionally since users are resynced on reconnect, this was duplicating members as it would get joins for already joined members.
This commit is contained in:
@@ -53,6 +53,7 @@ import net.runelite.client.events.PartyMemberAvatar;
|
|||||||
import net.runelite.client.party.messages.Join;
|
import net.runelite.client.party.messages.Join;
|
||||||
import net.runelite.client.party.messages.Part;
|
import net.runelite.client.party.messages.Part;
|
||||||
import net.runelite.client.party.messages.PartyChatMessage;
|
import net.runelite.client.party.messages.PartyChatMessage;
|
||||||
|
import net.runelite.client.party.messages.PartyMessage;
|
||||||
import net.runelite.client.party.messages.UserJoin;
|
import net.runelite.client.party.messages.UserJoin;
|
||||||
import net.runelite.client.party.messages.UserPart;
|
import net.runelite.client.party.messages.UserPart;
|
||||||
import net.runelite.client.party.messages.UserSync;
|
import net.runelite.client.party.messages.UserSync;
|
||||||
@@ -180,6 +181,22 @@ public class PartyService
|
|||||||
wsClient.send(new Join(partyId, USERNAME));
|
wsClient.send(new Join(partyId, USERNAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends PartyMessage> void send(T message)
|
||||||
|
{
|
||||||
|
if (!wsClient.isOpen())
|
||||||
|
{
|
||||||
|
log.debug("Reconnecting to server");
|
||||||
|
|
||||||
|
PartyMember local = getLocalMember();
|
||||||
|
members.removeIf(m -> m != local);
|
||||||
|
|
||||||
|
wsClient.connect();
|
||||||
|
wsClient.send(new Join(partyId, USERNAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
wsClient.send(message);
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe(priority = 1) // run prior to plugins so that the member is joined by the time the plugins see it.
|
@Subscribe(priority = 1) // run prior to plugins so that the member is joined by the time the plugins see it.
|
||||||
public void onUserJoin(final UserJoin message)
|
public void onUserJoin(final UserJoin message)
|
||||||
{
|
{
|
||||||
@@ -190,13 +207,17 @@ public class PartyService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final PartyMember partyMember = new PartyMember(message.getMemberId(), cleanUsername(message.getName()));
|
PartyMember partyMember = getMemberById(message.getMemberId());
|
||||||
members.add(partyMember);
|
if (partyMember == null)
|
||||||
|
{
|
||||||
|
partyMember = new PartyMember(message.getMemberId(), cleanUsername(message.getName()));
|
||||||
|
members.add(partyMember);
|
||||||
|
log.debug("User {} joins party, {} members", partyMember, members.size());
|
||||||
|
}
|
||||||
|
|
||||||
final PartyMember localMember = getLocalMember();
|
final PartyMember localMember = getLocalMember();
|
||||||
|
|
||||||
// Send info to other clients that this user successfully finished joining party
|
// Send info to other clients that this user successfully finished joining party
|
||||||
if (localMember != null && message.getMemberId().equals(localMember.getMemberId()))
|
if (localMember != null && localMember == partyMember)
|
||||||
{
|
{
|
||||||
final UserSync userSync = new UserSync();
|
final UserSync userSync = new UserSync();
|
||||||
userSync.setMemberId(message.getMemberId());
|
userSync.setMemberId(message.getMemberId());
|
||||||
@@ -207,7 +228,10 @@ public class PartyService
|
|||||||
@Subscribe(priority = 1) // run prior to plugins so that the member is removed by the time the plugins see it.
|
@Subscribe(priority = 1) // run prior to plugins so that the member is removed by the time the plugins see it.
|
||||||
public void onUserPart(final UserPart message)
|
public void onUserPart(final UserPart message)
|
||||||
{
|
{
|
||||||
members.removeIf(member -> member.getMemberId().equals(message.getMemberId()));
|
if (members.removeIf(member -> member.getMemberId().equals(message.getMemberId())))
|
||||||
|
{
|
||||||
|
log.debug("User {} leaves party, {} members", message.getMemberId(), members.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect()
|
void connect()
|
||||||
{
|
{
|
||||||
if (sessionId == null)
|
if (sessionId == null)
|
||||||
{
|
{
|
||||||
@@ -115,6 +115,11 @@ public class WSClient extends WebSocketListener implements AutoCloseable
|
|||||||
send(handshake);
|
send(handshake);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isOpen()
|
||||||
|
{
|
||||||
|
return webSocket != null;
|
||||||
|
}
|
||||||
|
|
||||||
public void registerMessage(final Class<? extends WebsocketMessage> message)
|
public void registerMessage(final Class<? extends WebsocketMessage> message)
|
||||||
{
|
{
|
||||||
if (messages.add(message))
|
if (messages.add(message))
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ public class DiscordPlugin extends Plugin
|
|||||||
discordUser.avatar
|
discordUser.avatar
|
||||||
);
|
);
|
||||||
userInfo.setMemberId(localMember.getMemberId());
|
userInfo.setMemberId(localMember.getMemberId());
|
||||||
wsClient.send(userInfo);
|
partyService.send(userInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class DpsCounterPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
final DpsUpdate dpsUpdate = new DpsUpdate(hit, isBoss);
|
final DpsUpdate dpsUpdate = new DpsUpdate(hit, isBoss);
|
||||||
dpsUpdate.setMemberId(localMember.getMemberId());
|
dpsUpdate.setMemberId(localMember.getMemberId());
|
||||||
wsClient.send(dpsUpdate);
|
partyService.send(dpsUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dpsConfig.bossDamage() && !isBoss)
|
if (dpsConfig.bossDamage() && !isBoss)
|
||||||
|
|||||||
@@ -104,9 +104,6 @@ public class PartyPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private PartyService party;
|
private PartyService party;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private WSClient ws;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@@ -266,7 +263,7 @@ public class PartyPlugin extends Plugin
|
|||||||
event.consume();
|
event.consume();
|
||||||
final TilePing tilePing = new TilePing(selectedSceneTile.getWorldLocation());
|
final TilePing tilePing = new TilePing(selectedSceneTile.getWorldLocation());
|
||||||
tilePing.setMemberId(party.getLocalMember().getMemberId());
|
tilePing.setMemberId(party.getLocalMember().getMemberId());
|
||||||
wsClient.send(tilePing);
|
party.send(tilePing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -326,7 +323,7 @@ public class PartyPlugin extends Plugin
|
|||||||
|
|
||||||
final LocationUpdate locationUpdate = new LocationUpdate(location);
|
final LocationUpdate locationUpdate = new LocationUpdate(location);
|
||||||
locationUpdate.setMemberId(localMember.getMemberId());
|
locationUpdate.setMemberId(localMember.getMemberId());
|
||||||
wsClient.send(locationUpdate);
|
party.send(locationUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -342,7 +339,7 @@ public class PartyPlugin extends Plugin
|
|||||||
// Request sync
|
// Request sync
|
||||||
final UserSync userSync = new UserSync();
|
final UserSync userSync = new UserSync();
|
||||||
userSync.setMemberId(party.getLocalMember().getMemberId());
|
userSync.setMemberId(party.getLocalMember().getMemberId());
|
||||||
ws.send(userSync);
|
party.send(userSync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,21 +439,21 @@ public class PartyPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
final SkillUpdate update = new SkillUpdate(Skill.HITPOINTS, currentHealth, realHealth);
|
final SkillUpdate update = new SkillUpdate(Skill.HITPOINTS, currentHealth, realHealth);
|
||||||
update.setMemberId(localMember.getMemberId());
|
update.setMemberId(localMember.getMemberId());
|
||||||
ws.send(update);
|
party.send(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceSend || currentPrayer != lastPray)
|
if (forceSend || currentPrayer != lastPray)
|
||||||
{
|
{
|
||||||
final SkillUpdate update = new SkillUpdate(Skill.PRAYER, currentPrayer, realPrayer);
|
final SkillUpdate update = new SkillUpdate(Skill.PRAYER, currentPrayer, realPrayer);
|
||||||
update.setMemberId(localMember.getMemberId());
|
update.setMemberId(localMember.getMemberId());
|
||||||
ws.send(update);
|
party.send(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceSend || !characterName.equals(lastCharacterName))
|
if (forceSend || !characterName.equals(lastCharacterName))
|
||||||
{
|
{
|
||||||
final CharacterNameUpdate update = new CharacterNameUpdate(characterName);
|
final CharacterNameUpdate update = new CharacterNameUpdate(characterName);
|
||||||
update.setMemberId(localMember.getMemberId());
|
update.setMemberId(localMember.getMemberId());
|
||||||
ws.send(update);
|
party.send(update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ import net.runelite.client.game.SpriteManager;
|
|||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.party.PartyMember;
|
import net.runelite.client.party.PartyMember;
|
||||||
import net.runelite.client.party.PartyService;
|
import net.runelite.client.party.PartyService;
|
||||||
import net.runelite.client.party.WSClient;
|
|
||||||
import net.runelite.client.party.messages.PartyChatMessage;
|
import net.runelite.client.party.messages.PartyChatMessage;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -156,9 +155,6 @@ public class RaidsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private PartyService party;
|
private PartyService party;
|
||||||
|
|
||||||
@Inject
|
|
||||||
private WSClient ws;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ChatCommandManager chatCommandManager;
|
private ChatCommandManager chatCommandManager;
|
||||||
|
|
||||||
@@ -494,7 +490,7 @@ public class RaidsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
final PartyChatMessage message = new PartyChatMessage(layoutMessage);
|
final PartyChatMessage message = new PartyChatMessage(layoutMessage);
|
||||||
message.setMemberId(localMember.getMemberId());
|
message.setMemberId(localMember.getMemberId());
|
||||||
ws.send(message);
|
party.send(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ public class SpecialCounterPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
final SpecialCounterUpdate specialCounterUpdate = new SpecialCounterUpdate(interactingId, specialWeapon, hit, client.getWorld(), localPlayerId);
|
final SpecialCounterUpdate specialCounterUpdate = new SpecialCounterUpdate(interactingId, specialWeapon, hit, client.getWorld(), localPlayerId);
|
||||||
specialCounterUpdate.setMemberId(party.getLocalMember().getMemberId());
|
specialCounterUpdate.setMemberId(party.getLocalMember().getMemberId());
|
||||||
wsClient.send(specialCounterUpdate);
|
party.send(specialCounterUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerInfoDrops.add(createSpecInfoDrop(specialWeapon, hit, localPlayerId));
|
playerInfoDrops.add(createSpecInfoDrop(specialWeapon, hit, localPlayerId));
|
||||||
|
|||||||
@@ -34,11 +34,10 @@ import net.runelite.client.Notifier;
|
|||||||
import net.runelite.client.chat.ChatClient;
|
import net.runelite.client.chat.ChatClient;
|
||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
|
import net.runelite.client.party.PartyService;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.util.ImageCapture;
|
import net.runelite.client.util.ImageCapture;
|
||||||
import net.runelite.client.party.PartyService;
|
|
||||||
import net.runelite.client.party.WSClient;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -92,10 +91,6 @@ public class RaidsPluginTest
|
|||||||
@Bind
|
@Bind
|
||||||
OverlayManager overlayManager;
|
OverlayManager overlayManager;
|
||||||
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
WSClient wsClient;
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@Bind
|
@Bind
|
||||||
RaidsConfig raidsConfig;
|
RaidsConfig raidsConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user