diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-29 20:50:27 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-29 20:50:27 +0000 |
commit | 56ffbc788019235e3a9cce49411a696acb914304 (patch) | |
tree | 911f26b33e00ec1e645f3a48d81845b3eb1cce57 /src/Network/Tox/Crypto/Handlers.hs | |
parent | 32ae0094bbc7d86431b93a0f5db6543eaccee793 (diff) |
initialize escape range in ncOutgoingIdMap, TODO comments
Diffstat (limited to 'src/Network/Tox/Crypto/Handlers.hs')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index ff00bd61..c731c82b 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -181,6 +181,8 @@ data NetCryptoSession = NCrypto | |||
181 | -- here if ncUnrecognizedHook will add them to ncHooks | 181 | -- here if ncUnrecognizedHook will add them to ncHooks |
182 | -- on an as-need basis. | 182 | -- on an as-need basis. |
183 | , ncOutgoingIdMap :: RangeMap TArray Word8 TVar | 183 | , ncOutgoingIdMap :: RangeMap TArray Word8 TVar |
184 | -- ^ used to lookup the outgoing id for a type, for now always an identity map | ||
185 | -- TODO: need 2 more outgoing id maps for escape-lossy and escape-lossless (group msgs) | ||
184 | , ncAllSessions :: NetCryptoSessions -- ^ may be needed if one net-crypto session | 186 | , ncAllSessions :: NetCryptoSessions -- ^ may be needed if one net-crypto session |
185 | -- needs to possibly start another, as is | 187 | -- needs to possibly start another, as is |
186 | -- the case in group chats | 188 | -- the case in group chats |
@@ -441,6 +443,12 @@ freshCryptoSession sessions | |||
441 | ncOutgoingIdMap0 <- atomically $ do | 443 | ncOutgoingIdMap0 <- atomically $ do |
442 | idmap <- emptySTMRangeMap | 444 | idmap <- emptySTMRangeMap |
443 | insertArrayAt idmap 0 (A.listArray (0,255) [0 .. 255]) | 445 | insertArrayAt idmap 0 (A.listArray (0,255) [0 .. 255]) |
446 | -- the 2 escape ranges are adjacent, so put them in one array: | ||
447 | insertArrayAt idmap 512 (A.listArray (512,1023) ( replicate 256 0xC7 -- lossy escaped | ||
448 | ++ replicate 256 0x63 -- lossless escapped | ||
449 | )) | ||
450 | -- lossless as separate range could have been done: | ||
451 | -- > insertArrayAt idmap 768 (A.listArray (768,1023) (replicate 256 0x63)) | ||
444 | return idmap | 452 | return idmap |
445 | ncView0 <- atomically $ newTVar (sessionView sessions) | 453 | ncView0 <- atomically $ newTVar (sessionView sessions) |
446 | pktq <- atomically $ PQ.new (inboundQueueCapacity sessions) 0 | 454 | pktq <- atomically $ PQ.new (inboundQueueCapacity sessions) 0 |