TerrariaPacketFactory

public enum TerrariaPacketFactory

This is an enum for decoding packets somewhat dynamically

  • Call this function for retriving a TerrariaPacket from an array of UInt8’s

    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))")
    }
    

    Declaration

    Swift

    public static func decodePacket(packet: [UInt8]) throws -> TerrariaPacket?