Skip to content

Commit

Permalink
Add copyrights.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extollite committed Sep 16, 2020
1 parent 96c5dad commit 021dd2b
Show file tree
Hide file tree
Showing 30 changed files with 104 additions and 73 deletions.
25 changes: 14 additions & 11 deletions Sources/RakNetSwift/Connection.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// Connection.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down Expand Up @@ -49,7 +50,7 @@ public class Connection {
var splitId : Int32 = 0

var lastUpdate : Int64 = Int64(NSDate().timeIntervalSince1970 * 1000)

var isActive = false

init(_ listener : Listener, _ mtu : Int32, _ address : SocketAddress){
Expand All @@ -75,13 +76,15 @@ public class Connection {
if(self.ackQueue.count > 0){
let pk = ACK(&self.ackQueue, Int32(self.mtu - 5))
var buf = self.listener!.channel!.allocator.buffer(capacity: Int(self.mtu - 4))
print("ack: \(self.ackQueue)")
pk.encode(&buf)
self.sendPacket(&buf)
}

if(self.nackQueue.count > 0){
let pk = NACK(&self.nackQueue, Int32(self.mtu - 5))
var buf = self.listener!.channel!.allocator.buffer(capacity: Int(self.mtu - 4))
print("nack: \(self.ackQueue)")
pk.encode(&buf)
self.sendPacket(&buf)
}
Expand Down Expand Up @@ -138,20 +141,20 @@ public class Connection {
let header = buf.readInteger(as: UInt8.self)!
buf.moveReaderIndex(to: 0)
let datagram = (header & Flags.FLAG_VALID) != 0
//print("id: \(header)")
print("id: \(header)")
if datagram {
if (header & Flags.FLAG_ACK) != 0 {
//print("ack")
print("ack")
self.handleACK(&buf)
} else if (header & Flags.FLAG_NACK) != 0 {
//print("nack")
print("nack")
self.handleNACK(&buf)
} else {
//print("datagram")
print("datagram")
self.handleDatagram(&buf)
}
} else {
//print("else")
print("else")
if(header < 0x80) {
if(self.state == State.CONNECTING) {
if(header == PacketIdentifiers.ConnectionRequest){
Expand Down Expand Up @@ -189,7 +192,7 @@ public class Connection {
packet.decode(&buf)
for seq in packet.packets {
for i in seq.start...seq.end {
//print("ackSeq: \(i)")
print("ackSeq: \(i)")
if self.sendDatagrams[Int32(i)] != nil {
for pk in self.sendDatagrams[Int32(i)]!.packets {
if pk != nil && pk!.needACK && pk!.messageIndex != -1 {
Expand Down Expand Up @@ -321,7 +324,7 @@ public class Connection {
}

let id = packet.buffer!.readInteger(as: UInt8.self)!
//print("packet: \(id)")
print("packet: \(id)")
packet.buffer!.moveReaderIndex(to: 0)
if(id < 0x80) {
if(self.state == State.CONNECTING) {
Expand Down Expand Up @@ -365,7 +368,7 @@ public class Connection {
self.addToQueue(sendPk, Priority.IMMEDIATE)
}
} else if self.state == .CONNECTED {
//print("con: \(id)")
print("con: \(id)")
self.listener!.connectionListener!.onEncapsulated(packet, self.address!)
}
}
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/ConnectionListener.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// ConnectionListener.swift
// RakNetSwift
//
// Created by Extollite on 16/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Listener.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// ConnectionListener.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Flags.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// Flags.swift
// RakNetSwift
//
// Created by Extollite on 10/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/ACK.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// ACK.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/AcknowledgePacket.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// AcknowledgePacket.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
6 changes: 3 additions & 3 deletions Sources/RakNetSwift/Protocol/Packets/ConnectedPing.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//
// File.swift
//
// ConnectedPing.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
import NIO

Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/ConnectedPong.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// ConnectedPong.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
7 changes: 4 additions & 3 deletions Sources/RakNetSwift/Protocol/Packets/ConnectionRequest.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// ConnectionRequest.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// ConnectionRequestAccepted.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/Datagram.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// Datagram.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// DisconnectNotification.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/EncapsulatedPacket.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// EncapsulatedPacket.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// IncompatibleProtocolVersion.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/NACK.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// NACK.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// NewIncomingConnection.swift
// RakNetSwift
//
// Created by Extollite on 13/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/OfflinePacket.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// OfflinePacket.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// OpenConnectionReply1.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// OpenConnectionReply2.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// OpenConnectionRequest1.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// OpenConnectionRequest2.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/Packet.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// Packet.swift
// RakNetSwift
//
// Created by Extollite on 10/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/PacketIdentifiers.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// PacketIdentifiers.swift
// RakNetSwift
//
// Created by Extollite on 10/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/UnconnectedPing.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// UnconnectedPing.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Packets/UnconnectedPong.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// UnconnectedPong.swift
// RakNetSwift
//
// Created by Extollite on 12/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
5 changes: 3 additions & 2 deletions Sources/RakNetSwift/Protocol/Priority.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//
// File.swift
//
// Priority.swift
// RakNetSwift
//
// Created by Extollite on 10/09/2020.
// Copyright © 2020 Extollite. All rights reserved.
//

import Foundation
Expand Down
Loading

0 comments on commit 021dd2b

Please sign in to comment.