-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broadcast station #63: Show connection status in ReaderTranslatorMac.
- Loading branch information
Showing
7 changed files
with
108 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// ConnectionStatus.swift | ||
// ReaderTranslator | ||
// | ||
// Created by Viktor Kushnerov on 13/12/19. | ||
// Copyright © 2019 Viktor Kushnerov. All rights reserved. | ||
// | ||
|
||
import Network | ||
|
||
enum ErrorConnection: Error { | ||
case listener(error: NWError) | ||
case connection(text: String) | ||
|
||
var status: String { | ||
switch self { | ||
case .listener(let error): | ||
return "\(error)" | ||
case .connection(let text): | ||
return text | ||
} | ||
} | ||
} | ||
|
||
enum ConnectionStatus { | ||
case none | ||
case started(name: String, passcode: String) | ||
case ready | ||
case connected | ||
case failed(error: ErrorConnection) | ||
|
||
var status: String { | ||
switch self { | ||
case .none: | ||
return "Start the server" | ||
case .ready: | ||
return "The server is ready" | ||
case .started(let name, let passcode): | ||
return "Pass code for \(name): \(passcode)" | ||
case .connected: | ||
return "The server is connected" | ||
case .failed(let error): | ||
return "The server: \(error.status)" | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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