mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
missing subslots is now a self message rather than an anonymous callback
This commit is contained in:
parent
490b04380f
commit
735f5f95cd
|
|
@ -108,7 +108,10 @@ object MiddlewareActor {
|
|||
final case class Close() extends Command
|
||||
|
||||
/** ... */
|
||||
private case class ProcessQueue() extends Command
|
||||
private case object ProcessQueue extends Command
|
||||
|
||||
/** ... */
|
||||
private case object ProcessMissingSubslots extends Command
|
||||
|
||||
/** Log inbound packets that are yet to be in proper order by sequence number */
|
||||
private case class InReorderEntry(packet: PlanetSidePacket, sequence: Int, time: Long)
|
||||
|
|
@ -426,7 +429,7 @@ class MiddlewareActor(
|
|||
packetProcessorDelay,
|
||||
packetProcessorDelay
|
||||
)(() => {
|
||||
context.self ! ProcessQueue()
|
||||
context.self ! ProcessQueue
|
||||
})
|
||||
active()
|
||||
|
||||
|
|
@ -480,10 +483,14 @@ class MiddlewareActor(
|
|||
}
|
||||
Behaviors.same
|
||||
|
||||
case ProcessQueue() =>
|
||||
case ProcessQueue =>
|
||||
processQueue()
|
||||
Behaviors.same
|
||||
|
||||
case ProcessMissingSubslots =>
|
||||
processRequestsForMissingSubslots()
|
||||
Behaviors.same
|
||||
|
||||
case Teardown() =>
|
||||
send(TeardownConnection(clientNonce))
|
||||
context.self ! Close()
|
||||
|
|
@ -843,6 +850,24 @@ class MiddlewareActor(
|
|||
*/
|
||||
private var activeSubslotsFunc: (Int, Int, ByteVector) => Unit = inSubslotNotMissing
|
||||
|
||||
/**
|
||||
* Start making requests for missing `SlottedMetaPackets`
|
||||
* if no prior requests were prepared.
|
||||
* Start the scheduled task and handle the dispatched requests.
|
||||
* @see `processRequestsForMissingSubslots`
|
||||
*/
|
||||
def askForMissingSubslots(): Unit = {
|
||||
if (subslotMissingProcessor.isCancelled) {
|
||||
subslotMissingProcessor = context.system.scheduler.scheduleWithFixedDelay(
|
||||
inSubslotMissingDelay,
|
||||
inSubslotMissingDelay
|
||||
)(() => {
|
||||
context.self ! ProcessMissingSubslots
|
||||
})
|
||||
processRequestsForMissingSubslots() //perform immediately
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What to do with a `SlottedMetaPacket` control packet normally.
|
||||
* The typical approach, when the subslot is the expected next number, is to merely receive the packet
|
||||
|
|
@ -875,6 +900,27 @@ class MiddlewareActor(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make requests for missing `SlottedMetaPackets`.
|
||||
* @see `inSubslotsMissingRequestFuncs`
|
||||
* @see `inSubslotsMissingRequestsFinished`
|
||||
* @see `RelatedA`
|
||||
*/
|
||||
def processRequestsForMissingSubslots(): Unit = {
|
||||
timesSubslotMissing += inSubslotsMissing.size
|
||||
inSubslotsMissing.foreach {
|
||||
case (subslot, attempt) =>
|
||||
val value = attempt - 1
|
||||
if (value > 0) {
|
||||
inSubslotsMissing(subslot) = value
|
||||
} else {
|
||||
inSubslotsMissing.remove(subslot)
|
||||
}
|
||||
send(RelatedA(0, subslot))
|
||||
}
|
||||
inSubslotsMissingRequestsFinished()
|
||||
}
|
||||
|
||||
/**
|
||||
* What to do with an inbound `SlottedMetaPacket` control packet when the subslots are in disarray.
|
||||
* Whenever a subslot arrives prior to the current highest, removing that subslot from the request list is possible.
|
||||
|
|
@ -918,38 +964,6 @@ class MiddlewareActor(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start making requests for missing `SlotedMetaPackets`
|
||||
* if no prior requests were prepared.
|
||||
* Start the scheduled task and handle the dispatched requests.
|
||||
* @see `inSubslotsMissingRequestFuncs`
|
||||
* @see `inSubslotsMissingRequestsFinished`
|
||||
* @see `RelatedA`
|
||||
*/
|
||||
def askForMissingSubslots(): Unit = {
|
||||
if (subslotMissingProcessor.isCancelled) {
|
||||
subslotMissingProcessor = context.system.scheduler.scheduleWithFixedDelay(
|
||||
initialDelay = 0.milliseconds,
|
||||
inSubslotMissingDelay
|
||||
)(() => {
|
||||
inSubslotsMissing.synchronized {
|
||||
timesSubslotMissing += inSubslotsMissing.size
|
||||
inSubslotsMissing.foreach {
|
||||
case (subslot, attempt) =>
|
||||
val value = attempt - 1
|
||||
if (value > 0) {
|
||||
inSubslotsMissing(subslot) = value
|
||||
} else {
|
||||
inSubslotsMissing.remove(subslot)
|
||||
}
|
||||
send(RelatedA(0, subslot))
|
||||
}
|
||||
inSubslotsMissingRequestsFinished()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split packet into multiple chunks (if necessary).
|
||||
* Split packets are wrapped in a `HandleGamePacket` and sent as `SlottedMetaPacket4`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue