# PSF-LoginServer - master - net.psforever.actors.net.MiddlewareActor
PSF - LoginServer - master - net.psforever.actors.net.MiddlewareActor
Keywords: PSF LoginServer master net.psforever.actors.net.MiddlewareActor

PSF-LoginServer - master < Back


# Packages

-  package root
  Definition Classes
    root
-  package net
  Definition Classes
    root
-  package psforever
  Definition Classes
    net
-  package actors
  Definition Classes
    psforever
-  package net
  Definition Classes
    actors
- LoginActor
- MiddlewareActor
- SocketActor

c

net.psforever.actors.net

# MiddlewareActor 

###
Companion object MiddlewareActor

#### class MiddlewareActor extends AnyRef

MiddlewareActor sits between the raw UDP socket and the "main" actors (either login or session) and handles crypto and control packets. This means it sets up cryptography, it decodes incoming packets, it encodes, bundles and splits outgoing packets, it handles things like requesting/resending lost packets and more.

Source
  MiddlewareActor.scala

Linear Supertypes
AnyRef, Any

Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. MiddlewareActor
2. AnyRef
3. Any

1. Hide All
2. Show All

Visibility

1. Public
2. Protected

### Instance Constructors

1.  new MiddlewareActor(context: ActorContext[Command], socket: ActorRef[Command], sender: InetSocketAddress, next: (ActorRef[Command], InetSocketAddress, String) => Behavior[PlanetSidePacket], connectionId: String)

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##: Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  var acceptedSmpSubslot: Int
5.  def active(): Behavior[Command]
6.  def activeNormal(packet: PlanetSidePacket, sequence: Int): Unit

   Properly handle the newly-arrived packet based on its sequence number.

   Properly handle the newly-arrived packet based on its sequence number. If the packet is in the proper order, or is considered old, by its sequence number, act on the packet immediately. If the sequence if higher than the next one expected, indicating that some packets may have been missed, put that packet to the side and active a resolution queue.

   packet

     the packet

   sequence

     the sequence number obtained from the packet

7.  def activeWithReordering(packet: PlanetSidePacket, sequence: Int): Unit

   Properly handle the newly-arrived packet based on its sequence number, with an ongoing resolution queue for managing out of sequence packets.

   Properly handle the newly-arrived packet based on its sequence number, with an ongoing resolution queue for managing out of sequence packets. If the packet is in the proper order, or is considered old, by its sequence number, act on the packet immediately. If the packet is considered a packet that was expected in the past, attempt to clear it from the queue and test the resolution queue for further work. If the sequence if higher than the next one expected, indicating that some packets may have been missed, add it to the resolution queue. Finally, act on the state of the resolution queue.

   packet

     the packet

   sequence

     the sequence number obtained from the packet

8.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
9.  def askForMissingSubslots(): Unit

   Start making requests for missing `SlotedMetaPackets` if no prior requests were prepared.

   Start making requests for missing `SlotedMetaPackets` if no prior requests were prepared. Start the scheduled task and handle the dispatched requests.

   See also

     `inSubslotsMissingRequestFuncs`

     `inSubslotsMissingRequestsFinished`

     `RelatedA`

10.  var clientNonce: Long
11.  def clone(): AnyRef
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.CloneNotSupportedException]) @native()
12.  def connectionClose(): Behavior[Command]

    End client-server ops.

    End client-server ops. End messaging capabilities.

13.  var crypto: Option[CryptoCoding]
14.  def cryptoFinish(dh: DiffieHellman, clientChallenge: ByteVector, serverChallenge: ByteVector): Behavior[Command]
15.  def cryptoSetup(): Behavior[Command]
16.  implicit val ec: ExecutionContextExecutor
17.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
18.  def equals(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef → Any
19.  implicit val executor: ExecutionContext
20.  def finalize(): Unit
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.Throwable])
21.  final def getClass(): Class[_ <: AnyRef]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
22.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
23.  def in(packet: Attempt[PlanetSidePacket]): Unit
24.  def in(packet: PlanetSidePacket): Behavior[Command]

    Handle incoming packet

25.  def inReorderQueueTest(): Unit

    If the inbound reorder queue is empty, do no more work on it until work is available.

    If the inbound reorder queue is empty, do no more work on it until work is available. Otherwise, do work on whatever is at the front of the queue, and do not test again until explicitly requested. Test the queue for more contents after removing content from it.

26.  val inReorderTimeout: FiniteDuration

    how long packets that are out of sequential order wait for the missing sequence before being expedited (ms)

27.  var inSequence: Int

    Latest incoming sequence number

28.  var inSubslot: Int

    Latest incoming subslot number

29.  val inSubslotMissingDelay: FiniteDuration

    how long to wait between repeated requests for packets with known missing subslot numbers (ms)

30.  val inSubslotMissingNumberOfAttempts: Int

    how many time to repeat the request for a packet with a known missing subslot number

31.  def inSubslotMissingRequests(slot: Int, subslot: Int, inner: ByteVector): Unit

    What to do with an inbound `SlottedMetaPacket` control packet when the subslots are in disarray.

    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. If the proper next subslot arrives, proceeding like normal is fine. Do not, however, send any `ResultB` confirmations until no more requests are outstanding.

    slot

      the SMP slot (related to the opcode)

    subslot

      the SMP subslot (related to the expected order of packets)

    inner

      the contents of this SMP

    See also

      `in`

      `inSubslotsMissingRequestsFinished`

      `PacketCoding.decodePacket`

32.  def inSubslotNotMissing(slot: Int, subslot: Int, inner: ByteVector): Unit

    What to do with a `SlottedMetaPacket` control packet normally.

    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 and dispatch a confirmation. When the subslot is farther ahead of what is expected, requests need to be logged for the missing subslots.

    slot

      the SMP slot (related to the opcode)

    subslot

      the SMP subslot (related to the expected order of packets)

    inner

      the contents of this SMP

    See also

      `askForMissingSubslots`

      `in`

      `inSubslotMissingRequests`

      `PacketCoding.decodePacket`

      `RelatedB`

33.  val inSubslotsMissing: Map[Int, Int]

    List of missing subslot numbers and attempts counter

34.  def inSubslotsMissingRequestsFinished(slot: Int = 0): Unit

    If there are no more requests for missing subslots, resume normal operations when acting upon inbound `SlottedMetaPacket` packets.

    If there are no more requests for missing subslots, resume normal operations when acting upon inbound `SlottedMetaPacket` packets.

    slot

      the optional slot to report the "first" `RelatedB` in a "while"

35.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
36.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
37.  val nextActor: ActorRef[PlanetSidePacket]
38.  def nextSequence: Int

    Increment the outbound sequence number.

    Increment the outbound sequence number. The previous sequence number is returned. The fidelity of the sequence field in packets is 16 bits, so wrap back to 0 after 65535.

39.  var nextSmpIndex: Int
40.  def nextSubslot: Int

    Increment the outbound subslot number.

    Increment the outbound subslot number. The previous subslot number is returned. The fidelity of the subslot field in `SlottedMetapacket`'s is 16 bits, so wrap back to 0 after 65535.

41.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
42.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
43.  val onSignal: PartialFunction[(ActorContext[Command], Signal), Behavior[Command]]
44.  def out(packet: PlanetSidePacket): Unit

    Handle outgoing packet

45.  val outQueue: Queue[(PlanetSidePacket, BitVector)]

    Queue of outgoing packets used for bundling and splitting

46.  val outQueueBundled: Queue[PlanetSidePacket]

    Queue of outgoing packets ready for sending

47.  var outSequence: Int

    Latest outbound sequence number; the current sequence is one less than this number

48.  var outSubslot: Int

    Latest outbound subslot number; the current subslot is one less than this number

49.  var packetProcessor: Cancellable

    Timer that handles the bundling and throttling of outgoing packets and resolves disorganized inbound packets

50.  val packetProcessorDelay: FiniteDuration

    Delay between runs of the packet bundler/resolver timer (ms); 250ms per network update (client upstream), so 10 runs of this bundling code every update

51.  val packetsBundledByThemselves: List[(PlanetSidePacket) => Boolean]

    Do not bundle these packets together with other packets

52.  val preparedSlottedMetaPackets: Array[SlottedMetaPacket]

    History of created `SlottedMetaPacket`s.

    History of created `SlottedMetaPacket`s. In case the client does not register receiving a packet by checking against packet subslot index numbers, it will dispatch a `RelatedA` packet, and the server will hopefully locate the packet where it has been backlogged. The client will also dispatch a `RelatedB` packet to indicate the packet with the highest subslot received. All packets with subslots less than that number have been received or will no longer be requested. The client and server supposedly maintain reciprocating mechanisms.

53.  def processInReorderQueue(): Unit

    Examine inbound packets that need to be reordered by sequence number and pass all packets that are now in the correct order and pass packets that have been kept waiting for too long in the queue.

    Examine inbound packets that need to be reordered by sequence number and pass all packets that are now in the correct order and pass packets that have been kept waiting for too long in the queue. Set the recorded inbound sequence number to belong to the greatest packet removed from the queue.

    See also

      `processInReorderQueueTimeoutOnly`

54.  def processInReorderQueueTimeoutOnly(): Unit

    Examine inbound packets that need to be reordered by sequence number and pass packets that have been kept waiting for too long in the queue.

    Examine inbound packets that need to be reordered by sequence number and pass packets that have been kept waiting for too long in the queue. Set the recorded inbound sequence number to belong to the greatest packet removed from the queue. This may run during the scheduled check on the in-order queue after the outbound bundling process.

55.  def processOutQueueBundle(): Unit

    Outbound packets that have not been caught by other guards need to be bundled and placed into `SlottedMetaPacket` messages.

    Outbound packets that have not been caught by other guards need to be bundled and placed into `SlottedMetaPacket` messages. Multiple packets in one bundle have to be placed into a `MultiPacketEx` message wrapper before being placed into the `SlottedMetaPacket`. Packets that are too big for the MTU must go on to be split into smaller portions that will be wrapped individually. Once queued, the first bundle is dispatched to the network.

56.  def processQueue(): Unit

    Periodically deal with these concerns: the bundling and throttling of outgoing packets and the reordering of out-of-sequence incoming packets.

57.  val random: SecureRandom
58.  def randomBytes(amount: Int): ByteVector

    A random series of bytes used as a challenge value.

    A random series of bytes used as a challenge value.

    amount

      the number of bytes

    returns

      a random series of bytes

59.  def send(packet: PlanetSidePacket, sequence: Option[Int], crypto: Option[CryptoCoding]): ByteVector
60.  def send(packet: PlanetSideGamePacket): ByteVector
61.  def send(packet: PlanetSideCryptoPacket): ByteVector
62.  def send(packet: PlanetSideControlPacket): ByteVector
63.  def sendFirstBundle(): Unit

    Take the first fully-prepared packet from the queue of prepared packets and send it to the client.

    Take the first fully-prepared packet from the queue of prepared packets and send it to the client. Assign the dispatched packet the latest sequence number. Do not call unless confident the the queue has at least one element.

    Exceptions thrown

      `NoSuchElementException` if there is no packet to dequeue

    See also

      `SlottedMetaPacket`

64.  var serverMACBuffer: ByteVector
65.  def smp(slot: Int, data: ByteVector): SlottedMetaPacket

    Create a new `SlottedMetaPacket` with the sequence number filled in and the packet added to the history.

    Create a new `SlottedMetaPacket` with the sequence number filled in and the packet added to the history.

    slot

      the slot for this packet, which influences the type of SMP

    data

      hexadecimal data, the encoded packets to be placed in the SMP

    returns

      the packet

66.  val smpHistoryLength: Int
67.  def splitPacket(packet: BitVector): Seq[PlanetSideControlPacket]

    Split packet into multiple chunks (if necessary).

    Split packet into multiple chunks (if necessary). Split packets are wrapped in a `HandleGamePacket` and sent as `SlottedMetaPacket4`. The purpose of `SlottedMetaPacket4` may or may not be to indicate a split packet.

68.  def start(): Behavior[Command]
69.  var subslotMissingProcessor: Cancellable

    Timer that handles the bundling and throttling of outgoing packets requesting packets with known subslot numbers

70.  final def synchronized[T0](arg0: => T0): T0
    Definition Classes
      AnyRef
71.  var timesInReorderQueue: Int

    end of life stat

72.  var timesSubslotMissing: Int

    end of life stat

73.  def toString(): String
    Definition Classes
      AnyRef → Any
74.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
75.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException])
76.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws(classOf[java.lang.InterruptedException]) @native()

### Inherited from AnyRef

### Inherited from Any

### Ungrouped