mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 07:24:53 +00:00
Append opportunistic overhang data consumer
This commit is contained in:
parent
e68c912ecb
commit
88ac2f35f7
2 changed files with 24 additions and 17 deletions
|
|
@ -3,6 +3,7 @@ package net.psforever.packet.game
|
||||||
|
|
||||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||||
import scodec.Codec
|
import scodec.Codec
|
||||||
|
import scodec.bits.ByteVector
|
||||||
import scodec.codecs._
|
import scodec.codecs._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,7 +20,8 @@ final case class VoiceHostRequest(
|
||||||
remote_host: Boolean,
|
remote_host: Boolean,
|
||||||
port: Int,
|
port: Int,
|
||||||
bandwidth: Int,
|
bandwidth: Int,
|
||||||
remote_ip: String
|
remote_ip: String,
|
||||||
|
data: ByteVector
|
||||||
) extends PlanetSideGamePacket {
|
) extends PlanetSideGamePacket {
|
||||||
require(port > 0)
|
require(port > 0)
|
||||||
require(port <= 65535)
|
require(port <= 65535)
|
||||||
|
|
@ -35,6 +37,7 @@ object VoiceHostRequest extends Marshallable[VoiceHostRequest] {
|
||||||
("remote_host" | bool) ::
|
("remote_host" | bool) ::
|
||||||
("port" | uint16L) ::
|
("port" | uint16L) ::
|
||||||
("bandwidth" | uint8L) ::
|
("bandwidth" | uint8L) ::
|
||||||
("remote_ip" | PacketHelpers.encodedStringAligned(7))
|
("remote_ip" | PacketHelpers.encodedStringAligned(7)) ::
|
||||||
|
("data" | bytes)
|
||||||
).as[VoiceHostRequest]
|
).as[VoiceHostRequest]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,25 +7,26 @@ import net.psforever.packet.game._
|
||||||
import scodec.bits._
|
import scodec.bits._
|
||||||
|
|
||||||
class VoiceHostRequestTest extends Specification {
|
class VoiceHostRequestTest extends Specification {
|
||||||
val string_request_local_75_high = hex"b0 25 80 01c000"
|
val string_request_local_75_high = hex"b0 2580 01 c0 00"
|
||||||
val string_request_local_1111_mid = hex"b0 2b 82 64c000"
|
val string_request_local_1111_mid = hex"b0 2b82 64 c0 00"
|
||||||
val string_request_local_1112_mid = hex"b0 2c 02 64c000"
|
val string_request_local_1112_mid = hex"b0 2c02 64 c0 00"
|
||||||
val string_request_remote_12345_high = hex"b0 9c 98 01c780 3131312e3232322e3132332e323334"
|
val string_request_remote_12345_high = hex"b0 9c98 01 c7 803131312e3232322e3132332e323334"
|
||||||
|
|
||||||
"decode local 75 high" in {
|
"decode local 75 high" in {
|
||||||
PacketCoding.decodePacket(string_request_local_75_high).require match {
|
PacketCoding.decodePacket(string_request_local_75_high).require match {
|
||||||
case VoiceHostRequest(remote_host, port, bandwidth, data) =>
|
case VoiceHostRequest(remote_host, port, bandwidth, server_ip, data) =>
|
||||||
remote_host mustEqual false
|
remote_host mustEqual false
|
||||||
port mustEqual 75
|
port mustEqual 75
|
||||||
bandwidth mustEqual 3
|
bandwidth mustEqual 3
|
||||||
data mustEqual ""
|
server_ip mustEqual ""
|
||||||
|
data mustEqual ByteVector.empty
|
||||||
case _ =>
|
case _ =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode local 75 high" in {
|
"encode local 75 high" in {
|
||||||
val msg = VoiceHostRequest(remote_host = false, 75, 3, "")
|
val msg = VoiceHostRequest(remote_host = false, 75, 3, "", ByteVector.empty)
|
||||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string_request_local_75_high
|
pkt mustEqual string_request_local_75_high
|
||||||
|
|
@ -33,18 +34,19 @@ class VoiceHostRequestTest extends Specification {
|
||||||
|
|
||||||
"decode local 1111 mid" in {
|
"decode local 1111 mid" in {
|
||||||
PacketCoding.decodePacket(string_request_local_1111_mid).require match {
|
PacketCoding.decodePacket(string_request_local_1111_mid).require match {
|
||||||
case VoiceHostRequest(remote_host, port, bandwidth, data) =>
|
case VoiceHostRequest(remote_host, port, bandwidth, server_ip, data) =>
|
||||||
remote_host mustEqual false
|
remote_host mustEqual false
|
||||||
port mustEqual 1111
|
port mustEqual 1111
|
||||||
bandwidth mustEqual 201
|
bandwidth mustEqual 201
|
||||||
data mustEqual ""
|
server_ip mustEqual ""
|
||||||
|
data mustEqual ByteVector.empty
|
||||||
case _ =>
|
case _ =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode local 1111 mid" in {
|
"encode local 1111 mid" in {
|
||||||
val msg = VoiceHostRequest(remote_host = false, 1111, 201, "")
|
val msg = VoiceHostRequest(remote_host = false, 1111, 201, "", ByteVector.empty)
|
||||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string_request_local_1111_mid
|
pkt mustEqual string_request_local_1111_mid
|
||||||
|
|
@ -52,18 +54,19 @@ class VoiceHostRequestTest extends Specification {
|
||||||
|
|
||||||
"decode local 1112 mid" in {
|
"decode local 1112 mid" in {
|
||||||
PacketCoding.decodePacket(string_request_local_1112_mid).require match {
|
PacketCoding.decodePacket(string_request_local_1112_mid).require match {
|
||||||
case VoiceHostRequest(remote_host, port, bandwidth, data) =>
|
case VoiceHostRequest(remote_host, port, bandwidth, server_ip, data) =>
|
||||||
remote_host mustEqual false
|
remote_host mustEqual false
|
||||||
port mustEqual 1112
|
port mustEqual 1112
|
||||||
bandwidth mustEqual 201
|
bandwidth mustEqual 201
|
||||||
data mustEqual ""
|
server_ip mustEqual ""
|
||||||
|
data mustEqual ByteVector.empty
|
||||||
case _ =>
|
case _ =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode local 1112 mid" in {
|
"encode local 1112 mid" in {
|
||||||
val msg = VoiceHostRequest(remote_host = false, 1112, 201, "")
|
val msg = VoiceHostRequest(remote_host = false, 1112, 201, "", ByteVector.empty)
|
||||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string_request_local_1112_mid
|
pkt mustEqual string_request_local_1112_mid
|
||||||
|
|
@ -71,18 +74,19 @@ class VoiceHostRequestTest extends Specification {
|
||||||
|
|
||||||
"decode remote 12345 high" in {
|
"decode remote 12345 high" in {
|
||||||
PacketCoding.decodePacket(string_request_remote_12345_high).require match {
|
PacketCoding.decodePacket(string_request_remote_12345_high).require match {
|
||||||
case VoiceHostRequest(remote, port, codec, server_ip) =>
|
case VoiceHostRequest(remote, port, codec, server_ip, data) =>
|
||||||
remote mustEqual true
|
remote mustEqual true
|
||||||
port mustEqual 12345
|
port mustEqual 12345
|
||||||
codec mustEqual 3
|
codec mustEqual 3
|
||||||
server_ip mustEqual "111.222.123.234"
|
server_ip mustEqual "111.222.123.234"
|
||||||
|
data mustEqual ByteVector.empty
|
||||||
case _ =>
|
case _ =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode remote 12345 high" in {
|
"encode remote 12345 high" in {
|
||||||
val msg = VoiceHostRequest(remote_host = true, port = 12345, bandwidth = 3, remote_ip = "111.222.123.234")
|
val msg = VoiceHostRequest(remote_host = true, port = 12345, bandwidth = 3, remote_ip = "111.222.123.234", ByteVector.empty)
|
||||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual string_request_remote_12345_high
|
pkt mustEqual string_request_remote_12345_high
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue