from Text import class Text(indexOf), instance Text String
derive class iTask TCPSettings
from Text import class Text(indexOf), instance Text String
derive class iTask TCPSettings
whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
//We stop
whileConnected _ _ (_,_,True) = (Ok "", Nothing, [], True)
whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
//We stop
whileConnected _ _ (_,_,True) = (Ok "", Nothing, [], True)
//No new data and nothing to send
whileConnected Nothing acc (_,[],_) = (Ok acc, Nothing, [], False)
//No new data and nothing to send
whileConnected Nothing acc (_,[],_) = (Ok acc, Nothing, [], False)
- whileConnected (Just newdata) acc (msgs,send,sendStopped)
- # (acc, nd) = process (acc +++ newdata)
+ whileConnected newdata acc (msgs,send,sendStopped)
+ # (acc, nd) = process (acc +++ fromMaybe "" newdata)
| isEmpty nd && isEmpty send = (Ok acc, Nothing, [], False)
= (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False)
process :: String -> (String, [String])
process s = case indexOf "\n" s of
-1 = (s, [])
| isEmpty nd && isEmpty send = (Ok acc, Nothing, [], False)
= (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False)
process :: String -> (String, [String])
process s = case indexOf "\n" s of
-1 = (s, [])
onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing)
onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing)