This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| VStack { | |
| Button("Server") { | |
| server?.start() | |
| } | |
| Spacer() | |
| Button("Client") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Client.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // AppDelegate.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import os.log | |
| import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // PeerConnection.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| browser.browseResultsChangedHandler = { results, changes in | |
| for result in results { | |
| if case NWEndpoint.service = result.endpoint { | |
| log("browser.browseResultsChangedHandler result: \(result)") | |
| if sharedConnection == nil { | |
| sharedConnection = Connection(endpoint: result.endpoint) | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| listener.newConnectionHandler = { newConnection in | |
| log("listener.newConnectionHandler \(newConnection)") | |
| if sharedConnection == nil { | |
| sharedConnection = Connection(connection: newConnection) | |
| } else { | |
| newConnection.cancel() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Client.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 30/11/2020. | |
| // | |
| import Foundation | |
| let client = Client() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Client.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Server.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network | |
| import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // PeerConnection.swift | |
| // MultiConnect | |
| // | |
| // Created by michal on 29/11/2020. | |
| // | |
| import Foundation | |
| import Network |