mostly spelling issues

This commit is contained in:
Fate-JH 2024-06-30 23:29:07 -04:00
parent eb3b180fcc
commit a53ab02c46

View file

@ -9,13 +9,37 @@ import akka.actor.typed.{ActorRef, Behavior, PostStop}
import akka.actor.typed.scaladsl.{ActorContext, Behaviors}
import net.psforever.packet.PlanetSidePacket
private[net] object SocketPanePortRotation {
/**
* Overrode constructor for `SocketPanePortRotation` entities.
* Copy constructor, essentially, that retains the internal current rotation index.
* @param rotation the previous rotation entity
* @return a copy of the previous rotation entity
*/
def apply(rotation: SocketPanePortRotation): SocketPanePortRotation = {
SocketPanePortRotation(rotation.portNumbers, rotation.currentIndex)
}
/**
* Overrode constructor for `SocketPanePortRotation` entities.
* Adda new port to the list of ports but retain the internal current rotation index.
* @param rotation the previous rotation entity
* @param newPort the new port number
* @return a copy of the previous rotation entity with an additional port that can be selected
*/
def apply(rotation: SocketPanePortRotation, newPort: Int): SocketPanePortRotation = {
SocketPanePortRotation(rotation.portNumbers :+ newPort, rotation.currentIndex)
}
}
/**
* For a given sequence of ports,
* cycle through port numbers until the last port number has been produced
* then start again from the first port number again.
* then start from the first port number again.
* @param portNumbers the sequence of ports to be cycled between
* @param index optional;
* the starting index in the sequence of ports
* the starting index in the sequence of ports;
* default is 0
*/
private[net] case class SocketPanePortRotation(
portNumbers: Seq[Int],
@ -35,29 +59,6 @@ private[net] case class SocketPanePortRotation(
}
}
object SocketPanePortRotation {
/**
* Overwritten constructor for `SocketPanePortRotation` entities.
* Copy constructor, essentially, that retains the internal current rotation index.
* @param rotation the previous rotation entity
* @return a copy of the previous rotation entity
*/
def apply(rotation: SocketPanePortRotation): SocketPanePortRotation = {
SocketPanePortRotation(rotation.portNumbers, rotation.currentIndex)
}
/**
* Overwritten constructor for `SocketPanePortRotation` entities.
* Adda new port to the list of ports but retain the internal current rotation index.
* @param rotation the previous rotation entity
* @param newPort the new port number
* @return a copy of the previous rotation entity with an additional port that can be selected
*/
def apply(rotation: SocketPanePortRotation, newPort: Int): SocketPanePortRotation = {
SocketPanePortRotation(rotation.portNumbers :+ newPort, rotation.currentIndex)
}
}
/**
* Information explaining how to manage a socket group.
* @param groupId moniker for the group
@ -88,7 +89,7 @@ object SocketPane {
val SocketPaneKey: ServiceKey[Command] = ServiceKey[SocketPane.Command](id = "socketPane")
/**
* Overwritten constructor for `SocketPane` entities.
* Overrode constructor for `SocketPane` entities.
* Registers the entity with the actor receptionist.
* @param setupInfo the details of the socket groups
* @return a `SocketPane` entity
@ -114,7 +115,7 @@ object SocketPane {
/**
* Management of sockets connecting to the network ports.
* <br><br>
* Connections to the networking ports are handled by the logic imposed by this class
* Connections to the networking ports are created by the logic imposed by this class
* and are handled by sockets that bind to those ports and accept or pass packets to game logic.
* This game logic is encapsulated by an anonymous function
* that is automatically implemented into a game logic machine (consumption and production)
@ -130,7 +131,7 @@ class SocketPane(
context: ActorContext[SocketPane.Command],
private val initialPortSetup: Seq[SocketSetup]
) {
private[this] val log = org.log4s.getLogger("SocketPane")
private[this] val log = org.log4s.getLogger
/** original socket group information, now properly flagged as "original" */
private var socketConfigs: Seq[SocketSetup] = initialPortSetup.map { setup => setup.copy(initial = true) }
@ -141,31 +142,31 @@ class SocketPane(
}.toArray
/** load balancing for redirecting newly discovered packet input to different sockets (ports);
* should be referenced externally to switch sockets;
* see SocketActor.GGetNextPort */
* see SocketActor.GetNextPort */
private var socketRotations: Array[SocketPanePortRotation] = initialPortSetup.map {
case SocketSetup(_, SocketSetupInfo(_, ports, _), _) => SocketPanePortRotation(ports)
}.toArray
log.info(s"configured ${socketActors.length} ports initially")
log.debug(s"sockets configured for ${socketActors.length} ports initially")
def start(): Behavior[SocketPane.Command] = {
Behaviors
.receiveMessagePartial[SocketPane.Command] {
case SocketPane.CreateNewSocket(key, _)
if !socketConfigs.exists { setup => setup.groupId == key } =>
log.warn(s"new port group $key does not exist and can not be appended to")
if !socketConfigs.exists { setup => setup.groupId.equals(key) } =>
log.warn(s"port group $key does not exist and can not be appended to")
Behaviors.same
case SocketPane.CreateNewSocket(groupId, port)
if socketConfigs
.find { setup => setup.groupId == groupId }
.find { setup => setup.groupId.equals(groupId) }
.exists { case SocketSetup(_, SocketSetupInfo(_, ports, _), _) => ports.contains(port) } =>
log.info(s"new port $port for group $groupId already supported")
Behaviors.same
case SocketPane.CreateNewSocket(groupId, port) =>
log.info(s"new socket to port $port created in $groupId")
val index = socketConfigs.indexWhere { setup => setup.groupId == groupId }
val index = socketConfigs.indexWhere { setup => setup.groupId.equals(groupId) }
val SocketSetup(_, SocketSetupInfo(address, ports, plan), _) = socketConfigs(index)
socketActors = socketActors :+
context.spawn(SocketActor(new InetSocketAddress(address, port), plan), name=s"world-socket-$port")
@ -176,7 +177,7 @@ class SocketPane(
Behaviors.same
case SocketPane.CreateNewSocketGroup(groupId, _)
if socketConfigs.exists { case SocketSetup(oldKey, _, _) => oldKey == groupId } =>
if socketConfigs.exists { case SocketSetup(oldKey, _, _) => oldKey.equals(groupId) } =>
log.warn(s"port group $groupId already exists and can not be created twice")
Behaviors.same
@ -190,7 +191,7 @@ class SocketPane(
Behaviors.same
case SocketPane.GetNextPort(groupId, replyTo) =>
socketConfigs.indexWhere { setup => setup.groupId == groupId } match {
socketConfigs.indexWhere { setup => setup.groupId.equals(groupId) } match {
case -1 =>
log.warn(s"port group $groupId does not exist")
case index =>