mirror of https://github.com/oxen-io/session-ios
Persist swarm cache & make access modifiers explicit
parent
cef9405473
commit
5af0ad03b9
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
internal extension LokiAPI {
|
||||||
|
|
||||||
|
internal struct Target : Hashable {
|
||||||
|
internal let address: String
|
||||||
|
internal let port: UInt16
|
||||||
|
|
||||||
|
internal init(address: String, port: UInt16) {
|
||||||
|
self.address = address
|
||||||
|
self.port = port
|
||||||
|
}
|
||||||
|
|
||||||
|
internal init(from targetWrapper: TargetWrapper) {
|
||||||
|
self.address = targetWrapper.address
|
||||||
|
self.port = targetWrapper.port
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum Method : String {
|
||||||
|
/// Only supported by snode targets.
|
||||||
|
case getSwarm = "get_snodes_for_pubkey"
|
||||||
|
/// Only supported by snode targets.
|
||||||
|
case getMessages = "retrieve"
|
||||||
|
case sendMessage = "store"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
@objc internal final class TargetWrapper : NSObject, NSCoding {
|
||||||
|
internal let address: String
|
||||||
|
internal let port: UInt16
|
||||||
|
|
||||||
|
internal init(from target: LokiAPI.Target) {
|
||||||
|
address = target.address
|
||||||
|
port = target.port
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal init?(coder: NSCoder) {
|
||||||
|
address = coder.decodeObject(forKey: "address") as! String
|
||||||
|
port = coder.decodeObject(forKey: "port") as! UInt16
|
||||||
|
super.init()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal func encode(with coder: NSCoder) {
|
||||||
|
coder.encode(address, forKey: "address")
|
||||||
|
coder.encode(port, forKey: "port")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue