Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public class SessionPanel(
public var metrics: SessionMetrics = SessionMetrics()
private var paused = false
private var streamNode: StreamTreeTableNode? = null
private var tickNode: TickTreeTableNode? = null
private var lastCycle = -1
private var rs3Connected = false
public val isActive: Boolean
get() = if (type.isRs3) rs3Connected else streamNode != null
Expand Down Expand Up @@ -176,20 +174,14 @@ public class SessionPanel(

if (streamNode != null) {

// Replace the stream node directly instead of purging it one by one
val oldHeader = streamNode.header
val streamNode =
if (oldHeader !=
null
) {
StreamTreeTableNode(oldHeader)
} else {
StreamTreeTableNode(streamNode.label ?: "")
}
// Retain the node identity used by this recording's delayed callbacks.
for (i in streamNode.childCount - 1 downTo 0) {
streamNode.remove(i)
}
streamNode.tickNode = null
addNodeAndExpand(streamNode, root, root.childCount)
this@SessionPanel.streamNode = streamNode
}
this@SessionPanel.tickNode = null
}
// make all buttons centered
toolbar.add(clearAllButton)
Expand Down Expand Up @@ -397,6 +389,7 @@ public class SessionPanel(
}

private inner class UiSessionMonitor : SessionMonitor<BinaryHeader> {
private var sessionStreamNode: StreamTreeTableNode? = null
private var lastCacheProvider: CacheProvider? = null
private val formatter =
OmitFilteredPropertyTreeFormatter(
Expand All @@ -406,31 +399,31 @@ public class SessionPanel(
) { this.lastCacheProvider?.get() ?: error("Cache unavailable") },
)

override fun forSession(header: BinaryHeader): SessionMonitor<BinaryHeader> = UiSessionMonitor()

override fun onCacheUpdate(cacheProvider: CacheProvider) {
this.lastCacheProvider = cacheProvider
}

override fun onLogin(header: BinaryHeader) {
// Update the session metrics data.
metrics.worldName = "World ${header.worldId} (${header.worldActivity})"
notifyMetricsChanged()

// Create a new root node for the logged in session.
SwingUtilities.invokeLater {
metrics.worldName = "World ${header.worldId} (${header.worldActivity})"
val streamNode = StreamTreeTableNode(header)
addNodeAndExpand(streamNode, root, root.childCount)
sessionStreamNode = streamNode
this@SessionPanel.streamNode = streamNode
notifyMetricsChanged()
}
}

override fun onLogout(header: BinaryHeader) {
// Update the session metrics data.
metrics.username = ""
notifyMetricsChanged()

// Clear the stream node.
SwingUtilities.invokeLater {
if (streamNode !== sessionStreamNode) return@invokeLater
metrics.username = ""
streamNode = null
// Keep sessionStreamNode for final rows still queued by the worker.
notifyMetricsChanged()
}
}

Expand All @@ -445,11 +438,14 @@ public class SessionPanel(
}

override fun onNameUpdate(name: String) {
metrics.username = name
sessionsPanel.updateTabTitle(this@SessionPanel, name)
notifyMetricsChanged()
if (metrics.userId != -1L && metrics.userHash != -1L) {
App.service.updateCredentials(name, metrics.userId, metrics.userHash)
SwingUtilities.invokeLater {
if (streamNode !== sessionStreamNode || streamNode == null) return@invokeLater
metrics.username = name
sessionsPanel.updateTabTitle(this@SessionPanel, name)
notifyMetricsChanged()
if (metrics.userId != -1L && metrics.userHash != -1L) {
App.service.updateCredentials(name, metrics.userId, metrics.userHash)
}
}
}

Expand All @@ -467,19 +463,24 @@ public class SessionPanel(
) {
if (paused) return
SwingUtilities.invokeLater {
val tickNode = findOrCreateTickNode(cycle)
val owner = sessionStreamNode ?: return@invokeLater
// Only discard rows when the user explicitly cleared their recording.
if (owner.parent !== root) return@invokeLater
val tickNode = findOrCreateTickNode(cycle, owner)
createMessageNode(tickNode, cycle, property, formatter)
}
}
}

private fun findOrCreateTickNode(tickNumber: Int): AbstractMutableTreeTableNode {
val streamNode = streamNode!!
var tickNode = tickNode
if (tickNode == null || lastCycle != tickNumber) {
lastCycle = tickNumber
private fun findOrCreateTickNode(
tickNumber: Int,
streamNode: StreamTreeTableNode = checkNotNull(this.streamNode),
): AbstractMutableTreeTableNode {
var tickNode = streamNode.tickNode
if (tickNode == null || streamNode.lastCycle != tickNumber) {
streamNode.lastCycle = tickNumber
tickNode = TickTreeTableNode(tickNumber)
this.tickNode = tickNode
streamNode.tickNode = tickNode
addNodeAndExpand(tickNode, streamNode, streamNode.childCount)
}
return tickNode
Expand All @@ -504,6 +505,9 @@ public class SessionPanel(
val header: BinaryHeader?,
val label: String?,
) : SessionBaseTreeTableNode() {
var tickNode: TickTreeTableNode? = null
var lastCycle: Int = -1

constructor(header: BinaryHeader) : this(header, null)

constructor(label: String) : this(null, label)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.metadata.Consistent
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateStockMarketSlot
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateStockMarketSlotV1
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v223.game.outgoing.decoder.prot.GameServerProt

@Consistent
internal class UpdateStockMarketSlotDecoder : ProxyMessageDecoder<UpdateStockMarketSlot> {
override val prot: ClientProt = GameServerProt.UPDATE_STOCKMARKET_SLOT
internal class UpdateStockMarketSlotV1Decoder : ProxyMessageDecoder<UpdateStockMarketSlotV1> {
override val prot: ClientProt = GameServerProt.UPDATE_STOCKMARKET_SLOT_V1

override fun decode(
buffer: JagByteBuf,
session: Session,
): UpdateStockMarketSlot {
): UpdateStockMarketSlotV1 {
val slot = buffer.g1()
return when (val status = buffer.g1()) {
0 -> {
UpdateStockMarketSlot(
UpdateStockMarketSlotV1(
slot,
UpdateStockMarketSlot.ResetStockMarketSlot,
UpdateStockMarketSlotV1.ResetStockMarketSlot,
)
}
else -> {
Expand All @@ -30,9 +30,9 @@ internal class UpdateStockMarketSlotDecoder : ProxyMessageDecoder<UpdateStockMar
val count = buffer.g4()
val completedCount = buffer.g4()
val completedGold = buffer.g4()
UpdateStockMarketSlot(
UpdateStockMarketSlotV1(
slot,
UpdateStockMarketSlot.SetStockMarketSlot(
UpdateStockMarketSlotV1.SetStockMarketSlot(
status,
obj,
price,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.metadata.Consistent
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateTradingPost
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateTradingPostV1
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v223.game.outgoing.decoder.prot.GameServerProt

@Consistent
internal class UpdateTradingPostDecoder : ProxyMessageDecoder<UpdateTradingPost> {
override val prot: ClientProt = GameServerProt.UPDATE_TRADINGPOST
internal class UpdateTradingPostV1Decoder : ProxyMessageDecoder<UpdateTradingPostV1> {
override val prot: ClientProt = GameServerProt.UPDATE_TRADINGPOST_V1

override fun decode(
buffer: JagByteBuf,
session: Session,
): UpdateTradingPost {
): UpdateTradingPostV1 {
val reset = buffer.g1() == 0
if (reset) {
return UpdateTradingPost(UpdateTradingPost.ResetTradingPost)
return UpdateTradingPostV1(UpdateTradingPostV1.ResetTradingPost)
}
val age = buffer.g8()
val obj = buffer.g2()
Expand All @@ -34,7 +34,7 @@ internal class UpdateTradingPostDecoder : ProxyMessageDecoder<UpdateTradingPost>
val price = buffer.g4()
val count = buffer.g4()
add(
UpdateTradingPost.TradingPostOffer(
UpdateTradingPostV1.TradingPostOffer(
name,
previousName,
world,
Expand All @@ -45,8 +45,8 @@ internal class UpdateTradingPostDecoder : ProxyMessageDecoder<UpdateTradingPost>
)
}
}
return UpdateTradingPost(
UpdateTradingPost.SetTradingPostOfferList(
return UpdateTradingPostV1(
UpdateTradingPostV1.SetTradingPostOfferList(
age,
obj,
status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public enum class GameServerProt(
MESSAGE_GAME(GameServerProtId.MESSAGE_GAME, Prot.VAR_BYTE),
CHAT_FILTER_SETTINGS(GameServerProtId.CHAT_FILTER_SETTINGS, 2),
CHAT_FILTER_SETTINGS_PRIVATECHAT(GameServerProtId.CHAT_FILTER_SETTINGS_PRIVATECHAT, 1),
UPDATE_TRADINGPOST(GameServerProtId.UPDATE_TRADINGPOST, Prot.VAR_SHORT),
UPDATE_STOCKMARKET_SLOT(GameServerProtId.UPDATE_STOCKMARKET_SLOT, 20),
UPDATE_TRADINGPOST_V1(GameServerProtId.UPDATE_TRADINGPOST_V1, Prot.VAR_SHORT),
UPDATE_STOCKMARKET_SLOT_V1(GameServerProtId.UPDATE_STOCKMARKET_SLOT_V1, 20),

// Misc. client state packets
HINT_ARROW(GameServerProtId.HINT_ARROW, 6),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ internal object GameServerProtId {
const val MAP_ANIM = 78
const val VARP_SYNC = 79
const val MIDI_SONG_WITHSECONDARY = 80
const val UPDATE_TRADINGPOST = 81
const val UPDATE_TRADINGPOST_V1 = 81
const val CHAT_FILTER_SETTINGS_PRIVATECHAT = 82
const val MESSAGE_PRIVATE = 83
const val MIDI_SONG_V1 = 84
const val UPDATE_STOCKMARKET_SLOT = 85
const val UPDATE_STOCKMARKET_SLOT_V1 = 85
const val IF_SETCOLOUR = 86
const val LOC_DEL = 87
const val MESSAGE_CLANCHANNEL_SYSTEM = 88
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateRu
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateRunWeightDecoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateStatV1Decoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateStatV2Decoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateStockMarketSlotDecoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateTradingPostDecoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateStockMarketSlotV1Decoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.misc.player.UpdateTradingPostV1Decoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.social.FriendListLoadedDecoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.social.MessagePrivateDecoder
import net.rsprox.protocol.v223.game.outgoing.decoder.codec.social.MessagePrivateEchoDecoder
Expand Down Expand Up @@ -252,8 +252,8 @@ internal object ServerMessageDecoderRepository {
bind(UpdateRunWeightDecoder())
bind(UpdateStatV2Decoder())
bind(UpdateStatV1Decoder())
bind(UpdateStockMarketSlotDecoder())
bind(UpdateTradingPostDecoder())
bind(UpdateStockMarketSlotV1Decoder())
bind(UpdateTradingPostV1Decoder())

bind(FriendListLoadedDecoder())
bind(MessagePrivateEchoDecoder(huffmanCodec))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.metadata.Consistent
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateStockMarketSlot
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateStockMarketSlotV1
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v224.game.outgoing.decoder.prot.GameServerProt

@Consistent
internal class UpdateStockMarketSlotDecoder : ProxyMessageDecoder<UpdateStockMarketSlot> {
override val prot: ClientProt = GameServerProt.UPDATE_STOCKMARKET_SLOT
internal class UpdateStockMarketSlotV1Decoder : ProxyMessageDecoder<UpdateStockMarketSlotV1> {
override val prot: ClientProt = GameServerProt.UPDATE_STOCKMARKET_SLOT_V1

override fun decode(
buffer: JagByteBuf,
session: Session,
): UpdateStockMarketSlot {
): UpdateStockMarketSlotV1 {
val slot = buffer.g1()
return when (val status = buffer.g1()) {
0 -> {
UpdateStockMarketSlot(
UpdateStockMarketSlotV1(
slot,
UpdateStockMarketSlot.ResetStockMarketSlot,
UpdateStockMarketSlotV1.ResetStockMarketSlot,
)
}
else -> {
Expand All @@ -30,9 +30,9 @@ internal class UpdateStockMarketSlotDecoder : ProxyMessageDecoder<UpdateStockMar
val count = buffer.g4()
val completedCount = buffer.g4()
val completedGold = buffer.g4()
UpdateStockMarketSlot(
UpdateStockMarketSlotV1(
slot,
UpdateStockMarketSlot.SetStockMarketSlot(
UpdateStockMarketSlotV1.SetStockMarketSlot(
status,
obj,
price,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import net.rsprot.buffer.JagByteBuf
import net.rsprot.protocol.ClientProt
import net.rsprot.protocol.metadata.Consistent
import net.rsprox.protocol.ProxyMessageDecoder
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateTradingPost
import net.rsprox.protocol.game.outgoing.model.misc.player.UpdateTradingPostV1
import net.rsprox.protocol.session.Session
import net.rsprox.protocol.v224.game.outgoing.decoder.prot.GameServerProt

@Consistent
internal class UpdateTradingPostDecoder : ProxyMessageDecoder<UpdateTradingPost> {
override val prot: ClientProt = GameServerProt.UPDATE_TRADINGPOST
internal class UpdateTradingPostV1Decoder : ProxyMessageDecoder<UpdateTradingPostV1> {
override val prot: ClientProt = GameServerProt.UPDATE_TRADINGPOST_V1

override fun decode(
buffer: JagByteBuf,
session: Session,
): UpdateTradingPost {
): UpdateTradingPostV1 {
val reset = buffer.g1() == 0
if (reset) {
return UpdateTradingPost(UpdateTradingPost.ResetTradingPost)
return UpdateTradingPostV1(UpdateTradingPostV1.ResetTradingPost)
}
val age = buffer.g8()
val obj = buffer.g2()
Expand All @@ -34,7 +34,7 @@ internal class UpdateTradingPostDecoder : ProxyMessageDecoder<UpdateTradingPost>
val price = buffer.g4()
val count = buffer.g4()
add(
UpdateTradingPost.TradingPostOffer(
UpdateTradingPostV1.TradingPostOffer(
name,
previousName,
world,
Expand All @@ -45,8 +45,8 @@ internal class UpdateTradingPostDecoder : ProxyMessageDecoder<UpdateTradingPost>
)
}
}
return UpdateTradingPost(
UpdateTradingPost.SetTradingPostOfferList(
return UpdateTradingPostV1(
UpdateTradingPostV1.SetTradingPostOfferList(
age,
obj,
status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public enum class GameServerProt(
MESSAGE_GAME(GameServerProtId.MESSAGE_GAME, Prot.VAR_BYTE),
CHAT_FILTER_SETTINGS(GameServerProtId.CHAT_FILTER_SETTINGS, 2),
CHAT_FILTER_SETTINGS_PRIVATECHAT(GameServerProtId.CHAT_FILTER_SETTINGS_PRIVATECHAT, 1),
UPDATE_TRADINGPOST(GameServerProtId.UPDATE_TRADINGPOST, Prot.VAR_SHORT),
UPDATE_STOCKMARKET_SLOT(GameServerProtId.UPDATE_STOCKMARKET_SLOT, 20),
UPDATE_TRADINGPOST_V1(GameServerProtId.UPDATE_TRADINGPOST_V1, Prot.VAR_SHORT),
UPDATE_STOCKMARKET_SLOT_V1(GameServerProtId.UPDATE_STOCKMARKET_SLOT_V1, 20),

// Misc. client state packets
HINT_ARROW(GameServerProtId.HINT_ARROW, 6),
Expand Down
Loading
Loading