Verified Commit 2eac292b authored by Camil Staps's avatar Camil Staps 🚀

Simplify TCP connection

parent 6c934fc9
......@@ -147,13 +147,13 @@ where
| any isNothing lines
# json = toString (toJSON {type="err", val="invalid json"}) +++ "\n"
= (Ok local, Just share, [json], False)
# share & tcpRx = foldr (\(Just msg) -> 'Data.Map'.alter (add msg) processId) tcpRx lines
# share & tcpRx = 'Data.Map'.alter (add [l \\ Just l <- lines]) processId tcpRx
= (Ok local, Just share, [], False)
where
add :: !TCPMsg !(Maybe [TCPMsg]) -> Maybe [TCPMsg]
add msg mbMsgs = case mbMsgs of
Just msgs -> Just (msgs++[msg])
Nothing -> Just [msg]
add :: ![TCPMsg] !(Maybe [TCPMsg]) -> Maybe [TCPMsg]
add lines mbMsgs = case mbMsgs of
Just msgs -> Just (msgs++lines)
Nothing -> Just lines
onShareChange :: !TCPLocal !TCPShare -> (!MaybeErrorString TCPLocal, !Maybe TCPShare, ![String], !Bool)
onShareChange local=:{processId} share=:{tcpTx}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment