From 56ffbc788019235e3a9cce49411a696acb914304 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 29 May 2018 20:50:27 +0000 Subject: initialize escape range in ncOutgoingIdMap, TODO comments --- src/Network/Tox/Crypto/Handlers.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Network') 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 -- here if ncUnrecognizedHook will add them to ncHooks -- on an as-need basis. , ncOutgoingIdMap :: RangeMap TArray Word8 TVar + -- ^ used to lookup the outgoing id for a type, for now always an identity map + -- TODO: need 2 more outgoing id maps for escape-lossy and escape-lossless (group msgs) , ncAllSessions :: NetCryptoSessions -- ^ may be needed if one net-crypto session -- needs to possibly start another, as is -- the case in group chats @@ -441,6 +443,12 @@ freshCryptoSession sessions ncOutgoingIdMap0 <- atomically $ do idmap <- emptySTMRangeMap insertArrayAt idmap 0 (A.listArray (0,255) [0 .. 255]) + -- the 2 escape ranges are adjacent, so put them in one array: + insertArrayAt idmap 512 (A.listArray (512,1023) ( replicate 256 0xC7 -- lossy escaped + ++ replicate 256 0x63 -- lossless escapped + )) + -- lossless as separate range could have been done: + -- > insertArrayAt idmap 768 (A.listArray (768,1023) (replicate 256 0x63)) return idmap ncView0 <- atomically $ newTVar (sessionView sessions) pktq <- atomically $ PQ.new (inboundQueueCapacity sessions) 0 -- cgit v1.2.3