mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-08-28 21:18:20 +00:00
send CRLF, allow CRLF in input
This commit is contained in:
+7
-8
@@ -2,7 +2,6 @@
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PolyKinds #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
@@ -19,16 +18,16 @@ import Data.Kind
|
||||
import Data.Time.Clock
|
||||
import Data.Time.ISO8601
|
||||
|
||||
data SParty :: Party -> Type where
|
||||
SBroker :: SParty 'Broker
|
||||
SRecipient :: SParty 'Recipient
|
||||
SSender :: SParty 'Sender
|
||||
|
||||
deriving instance Show (SParty a)
|
||||
|
||||
data Party = Broker | Recipient | Sender
|
||||
deriving (Show)
|
||||
|
||||
data SParty :: Party -> Type where
|
||||
SBroker :: SParty Broker
|
||||
SRecipient :: SParty Recipient
|
||||
SSender :: SParty Sender
|
||||
|
||||
deriving instance Show (SParty a)
|
||||
|
||||
data Cmd where
|
||||
Cmd :: SParty a -> Command a -> Cmd
|
||||
|
||||
|
||||
+4
-1
@@ -62,11 +62,14 @@ startTCPClient host port = liftIO . withSocketsDo $ resolve >>= open
|
||||
runTCPClient :: MonadUnliftIO m => HostName -> ServiceName -> (Handle -> m a) -> m a
|
||||
runTCPClient host port = E.bracket (startTCPClient host port) IO.hClose
|
||||
|
||||
smpNewlineMode :: NewlineMode
|
||||
smpNewlineMode = NewlineMode {inputNL = CRLF, outputNL = CRLF}
|
||||
|
||||
getSocketHandle :: MonadIO m => Socket -> m Handle
|
||||
getSocketHandle conn = liftIO $ do
|
||||
h <- socketToHandle conn ReadWriteMode
|
||||
hSetBinaryMode h True
|
||||
hSetNewlineMode h universalNewlineMode
|
||||
hSetNewlineMode h smpNewlineMode
|
||||
hSetBuffering h LineBuffering
|
||||
return h
|
||||
|
||||
|
||||
Reference in New Issue
Block a user