From 86f6eb5eabe7de9f97f1cdebdc08e45bd3981177 Mon Sep 17 00:00:00 2001 From: Jedrzej <42713788+Extollite@users.noreply.github.com> Date: Fri, 18 Sep 2020 17:31:37 +0200 Subject: [PATCH] Allow access to encapsulated. --- Sources/RakNetSwift/Listener.swift | 4 ---- .../RakNetSwift/Protocol/Packets/AcknowledgePacket.swift | 5 +++-- .../RakNetSwift/Protocol/Packets/EncapsulatedPacket.swift | 6 +++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Sources/RakNetSwift/Listener.swift b/Sources/RakNetSwift/Listener.swift index 3688b4b..102b33c 100644 --- a/Sources/RakNetSwift/Listener.swift +++ b/Sources/RakNetSwift/Listener.swift @@ -33,10 +33,6 @@ public class Listener { var connectionListener : ConnectionListener? - public init () { - - } - public func listen(_ connectionListener : T?, _ serverInfo : ServerInfo, _ host : String = "0.0.0.0", _ port : Int = 19132) -> EventLoopFuture? { let handler = ServerDatagramHandler() handler.listener = self diff --git a/Sources/RakNetSwift/Protocol/Packets/AcknowledgePacket.swift b/Sources/RakNetSwift/Protocol/Packets/AcknowledgePacket.swift index e276c0c..4533f61 100644 --- a/Sources/RakNetSwift/Protocol/Packets/AcknowledgePacket.swift +++ b/Sources/RakNetSwift/Protocol/Packets/AcknowledgePacket.swift @@ -63,15 +63,16 @@ class AcknowledgePacket : Packet { if(self.mtu >= 4) { self.packets.append(Entry(start)) self.mtu -= 4 + firstIndex = i } - firstIndex = i + //self.packets.append(Entry(start)) } else if(start != end){ if(self.mtu >= 7){ self.packets.append(Entry(start, end)) self.mtu -= 7 + firstIndex = i } - firstIndex = i //self.packets.append(Entry(start, end)) } if(self.packets.count > 0){ diff --git a/Sources/RakNetSwift/Protocol/Packets/EncapsulatedPacket.swift b/Sources/RakNetSwift/Protocol/Packets/EncapsulatedPacket.swift index a319055..0a1f80a 100644 --- a/Sources/RakNetSwift/Protocol/Packets/EncapsulatedPacket.swift +++ b/Sources/RakNetSwift/Protocol/Packets/EncapsulatedPacket.swift @@ -20,12 +20,12 @@ public class EncapsulatedPacket { var splitCount : Int32 = 0 var splitId : Int32 = 0 var splitIndex : Int32 = 0 - var buffer : ByteBuffer? + public var buffer : ByteBuffer? var needACK = false var ackId : Int32 = 0 - func decode(_ buf : inout ByteBuffer) { + public func decode(_ buf : inout ByteBuffer) { let flags = Int32(buf.readInteger(as: Int8.self)!) reliability = Reliability.fromId((flags & 0b11100000) >> 5) split = (flags & 0b00010000) != 0 @@ -54,7 +54,7 @@ public class EncapsulatedPacket { buffer = buf.readSlice(length: Int(size))! } - func encode(_ buf : inout ByteBuffer) { + public func encode(_ buf : inout ByteBuffer) { var flags = reliability!.id << Int32(5) if (split) {