forgot to commit
[mTask.git] / Devices / mTaskTCP.icl
index 52832d6..4ebc1ac 100644 (file)
@@ -23,7 +23,7 @@ instance MTaskDuplex TCPSettings where
                                onDisconnect=onDisconnect} @! ()
                where
                        onConnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
-                       onConnect acc (msgs,send,sendStopped) = (Ok acc, Just (msgs,[],sendStopped), map encode send, False)
+                       onConnect acc (msgs,send,sendStopped) = (Ok "", Just (msgs,[],sendStopped), map encode send, False)
 
                        whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
                        //We stop
@@ -37,9 +37,11 @@ instance MTaskDuplex TCPSettings where
                        = (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False)
 
                        process :: String -> (String, [String])
-                       process s = case indexOf "\n" s of
+                       process s
+                       | not (trace_tn ("process: " +++ toString (toJSON s))) = undef
+                       = case indexOf "\n" s of
                                -1 = (s, [])
-                               i = appSnd (\ss->[s % (0,i):ss]) (process (s % (i+1, size s)))
+                               i = appSnd (\ss->[s % (0,i-1):ss]) (process (s % (i+1, size s)))
                        
                        onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
                        onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing)