diff options
author | Joe Crayne <joe@jerkface.net> | 2018-09-09 02:32:20 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-10-03 06:49:55 -0400 |
commit | fbf9890a6bcd4e6212b5947f908bc34f233b279d (patch) | |
tree | 1ceee1e2dcc2a1bb53c6ca03d0d4986099381630 /src/Network | |
parent | 037508fe7ed09e3b4f4c00b7778f6c0dc4a3d5f9 (diff) |
Moved resolving duty to Connection manager.
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Tox/AggregateSession.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Network/Tox/AggregateSession.hs b/src/Network/Tox/AggregateSession.hs index d4497c48..26e7153a 100644 --- a/src/Network/Tox/AggregateSession.hs +++ b/src/Network/Tox/AggregateSession.hs | |||
@@ -9,6 +9,7 @@ module Network.Tox.AggregateSession | |||
9 | , newAggregateSession | 9 | , newAggregateSession |
10 | , aggregateStatus | 10 | , aggregateStatus |
11 | , checkCompatible | 11 | , checkCompatible |
12 | , compatibleKeys | ||
12 | , AddResult(..) | 13 | , AddResult(..) |
13 | , addSession | 14 | , addSession |
14 | , DelResult(..) | 15 | , DelResult(..) |
@@ -321,3 +322,16 @@ checkCompatible me them c = do | |||
321 | con:_ -> Just $ ncTheirPublicKey (singleSession con) == them | 322 | con:_ -> Just $ ncTheirPublicKey (singleSession con) == them |
322 | && (ncMyPublicKey $ singleSession con) == me | 323 | && (ncMyPublicKey $ singleSession con) == me |
323 | [] -> Nothing | 324 | [] -> Nothing |
325 | |||
326 | -- | Returns the local and remote keys that are compatible with this aggregate. | ||
327 | -- If 'Nothing' Is returned, then either no key is compatible ('closeAll' was | ||
328 | -- called) or all keys are compatible because no sessions have been associated. | ||
329 | compatibleKeys :: AggregateSession -> STM (Maybe (PublicKey,PublicKey)) | ||
330 | compatibleKeys c = do | ||
331 | isclosed <- isClosedTMChan (contactChannel c) | ||
332 | imap <- readTVar (contactSession c) | ||
333 | return $ case IntMap.elems imap of | ||
334 | _ | isclosed -> Nothing -- none. | ||
335 | con:_ -> Just ( ncMyPublicKey $ singleSession con | ||
336 | , ncTheirPublicKey (singleSession con)) | ||
337 | [] -> Nothing -- any. | ||