Skip to content
Snippets Groups Projects
Commit 7c279cf1 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add Connection.getPartner method

parent 109d4211
No related branches found
No related tags found
1 merge request!2Bindings API wrapper
......@@ -2,6 +2,7 @@ import Bindings
public struct Connection {
public var isAuthenticated: () -> Bool
public var getPartner: () -> Data
public var send: MessageSender
public var listen: MessageListener
}
......@@ -12,6 +13,12 @@ extension Connection {
) -> Connection {
Connection(
isAuthenticated: { false },
getPartner: {
guard let data = bindingsConnection.getPartner() else {
fatalError("BindingsConnection.getPartner returned `nil`")
}
return data
},
send: .live(bindingsConnection: bindingsConnection),
listen: .live(bindingsConnection: bindingsConnection)
)
......@@ -22,6 +29,12 @@ extension Connection {
) -> Connection {
Connection(
isAuthenticated: bindingsAuthenticatedConnection.isAuthenticated,
getPartner: {
guard let data = bindingsAuthenticatedConnection.getPartner() else {
fatalError("BindingsAuthenticatedConnection.getPartner returned `nil`")
}
return data
},
send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection),
listen: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection)
)
......@@ -32,6 +45,7 @@ extension Connection {
extension Connection {
public static let failing = Connection(
isAuthenticated: { fatalError("Not implemented") },
getPartner: { fatalError("Not implemented") },
send: .failing,
listen: .failing
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment