TerrariaPacket
public protocol TerrariaPacket
This is a protocol in which all TerrariaPackets should conform to.
-
Undocumented
Declaration
Swift
var bytes: [UInt8] { get set } -
Undocumented
Declaration
Swift
var length: UInt16 { get set } -
Undocumented
Declaration
Swift
var context: TerrariaPacketContext { get set } -
Undocumented
Declaration
Swift
var packetType: TerrariaPacketType { get set } -
Undocumented
Declaration
Swift
var payload: [UInt8] { get set } -
Undocumented
Declaration
Swift
init() -
Call this function to encode the payload of a terraria packet.
Declaration
Swift
mutating func encodePayload() throws -
Call this function to decode the payload of a terraria packet.
Declaration
Swift
mutating func decodePayload() throws -
init(from:Extension method) Undocumented
Declaration
Swift
public init(from data: [UInt8]) -
getType()Extension methodUndocumented
Declaration
Swift
public func getType() -> TerrariaPacketType -
decode(_:Extension method) Call this function to conveniently decode the header and the payload of a given packet.
Usage Example:
let packetData: [UInt8] = [25, 0, 13, 2, 72, 20, 0, 0, 0, 255, 16, 129, 69, 0, 240, 237, 69, 23, 143, 26, 65, 0, 0, 0, 0] guard var packet = try? TerrariaPacketFactory.decodePacket(packet: packetData) else { print("Parse failed!") print("Failed bytes: \(packetData))") } do{ try packet.decode(.ServerToClient) print("Decoded Packet Bytes: \(packet.bytes))") }catch{ print("Decode failed...") print("Failed Packet Bytes: \(packet.bytes))") return }Declaration
Swift
mutating public mutating func decode(_ context: TerrariaPacketContext) throws -
decodeHeader()Extension methodCall this function to decode the header of a terraria packet.
Declaration
Swift
mutating public mutating func decodeHeader() throws -
encode()Extension methodCall this function to encode the header and payload of a terraria packet.
Declaration
Swift
mutating public mutating func encode() throws -
encoded()Extension methodCall this function to conveniently encode a terraria packet and retrieve the packet byte array.
Declaration
Swift
mutating public mutating func encoded() throws -> [UInt8] -
encodeHeader()Extension methodCall this function to encode the header of a terraria packet.
Declaration
Swift
mutating public mutating func encodeHeader() throws -
calculateLength()Extension methodCall this function to calculate the length of a terraria packet.
Declaration
Swift
mutating public mutating func calculateLength() -
getLength()Extension methodCall this function to retrieve the length of a terraria packet.
Declaration
Swift
public func getLength() -> UInt16
TerrariaPacket Protocol Reference