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

Simplify TCP connection

parent 6c934fc9
...@@ -147,13 +147,13 @@ where ...@@ -147,13 +147,13 @@ where
| any isNothing lines | any isNothing lines
# json = toString (toJSON {type="err", val="invalid json"}) +++ "\n" # json = toString (toJSON {type="err", val="invalid json"}) +++ "\n"
= (Ok local, Just share, [json], False) = (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) = (Ok local, Just share, [], False)
where where
add :: !TCPMsg !(Maybe [TCPMsg]) -> Maybe [TCPMsg] add :: ![TCPMsg] !(Maybe [TCPMsg]) -> Maybe [TCPMsg]
add msg mbMsgs = case mbMsgs of add lines mbMsgs = case mbMsgs of
Just msgs -> Just (msgs++[msg]) Just msgs -> Just (msgs++lines)
Nothing -> Just [msg] Nothing -> Just lines
onShareChange :: !TCPLocal !TCPShare -> (!MaybeErrorString TCPLocal, !Maybe TCPShare, ![String], !Bool) onShareChange :: !TCPLocal !TCPShare -> (!MaybeErrorString TCPLocal, !Maybe TCPShare, ![String], !Bool)
onShareChange local=:{processId} share=:{tcpTx} 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