diff --git a/Package.resolved b/Package.resolved index 71e4e5f..eeece2d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -42,8 +42,8 @@ "repositoryURL": "https://github.com/apple/swift-nio.git", "state": { "branch": null, - "revision": "96db8838be60fcbb993fa738e1120fb7f4b99c43", - "version": "2.22.1" + "revision": "c3e2359c55cd8b47207ab7363b77c9c398a95294", + "version": "2.23.0" } }, { @@ -51,7 +51,7 @@ "repositoryURL": "https://github.com/Extollite/swift-raknet.git", "state": { "branch": "master", - "revision": "1bec70f38856f1e8b9f814826d513942cc253460", + "revision": "af99b14bfae28c4ae88746cad894f9f059b4b653", "version": null } }, @@ -60,7 +60,7 @@ "repositoryURL": "https://github.com/Extollite/swift-transferpe.git", "state": { "branch": "master", - "revision": "b872a1a298a20107a44ca2ce2453b35edf24ba45", + "revision": "109928246c49b8a83e34571a31f7a7bcf5d1016e", "version": null } }, diff --git a/Sources/TransferApp/main.swift b/Sources/TransferApp/main.swift index f6eb89e..f1405d9 100644 --- a/Sources/TransferApp/main.swift +++ b/Sources/TransferApp/main.swift @@ -1,10 +1,21 @@ import Foundation import TransferPe +import NIO +import RakNetSwift let arguments: [String] = Array(CommandLine.arguments.dropFirst()) var ip = "mcpe.to" var port = 19132 +var group = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) + +defer { + do { + try group.syncShutdownGracefully() + } catch { + print(error) + } +} if(arguments.count == 1){ ip = arguments[0] @@ -13,14 +24,16 @@ if(arguments.count == 1){ port = Int(arguments[1])! } -let server = TransferPe(ip, port) -let closeFuture = server.run() + +let server = TransferPe(ip, port, false, withHandler: { + print("Server turned off!") +}) signal(SIGINT) { s in server.close() } -do { - try closeFuture!.wait() -} catch { - print(error) +server.run(group) + +while(server.isRunning) { + //NOOP }