diff --git a/src/ConnStore.hs b/src/ConnStore.hs index 6a8bf6946..0cdf84af7 100644 --- a/src/ConnStore.hs +++ b/src/ConnStore.hs @@ -34,3 +34,8 @@ newConnection rKey = senderKey = Nothing, status = ConnActive } + +-- class MonadMsgStore s m where +-- addMsg :: s -> SenderId -> MsgBody -> m (Either ErrorType ()) +-- getMsg :: s -> RecipientId -> m (Either ErrorType Message) +-- delMsg :: s -> RecipientId -> m (Either ErrorType ()) diff --git a/src/Transmission.hs b/src/Transmission.hs index e8c7c4197..fa1e9c3fb 100644 --- a/src/Transmission.hs +++ b/src/Transmission.hs @@ -123,7 +123,7 @@ type Timestamp = Encoded type MsgBody = B.ByteString -data ErrorType = UNKNOWN | PROHIBITED | SYNTAX Int | AUTH | INTERNAL deriving (Show, Eq) +data ErrorType = UNKNOWN | PROHIBITED | SYNTAX Int | SIZE | AUTH | INTERNAL deriving (Show, Eq) errBadParameters :: Int errBadParameters = 2 @@ -139,6 +139,3 @@ errNoConnectionId = 5 errMessageBody :: Int errMessageBody = 6 - -errMessageBodySize :: Int -errMessageBodySize = 7 diff --git a/src/Transport.hs b/src/Transport.hs index 33931a72f..4c49c5937 100644 --- a/src/Transport.hs +++ b/src/Transport.hs @@ -152,5 +152,5 @@ tGet fromParty h = do Just size -> do body <- getBytes h size s <- getLn h - return if null s then Right body else Left $ SYNTAX errMessageBodySize + return if null s then Right body else Left SIZE Nothing -> return . Left $ SYNTAX errMessageBody diff --git a/tests/Test.hs b/tests/Test.hs index caa839706..f5aca4a7b 100644 --- a/tests/Test.hs +++ b/tests/Test.hs @@ -143,7 +143,7 @@ syntaxTests = do it "many parameters" $ [("123", "1", "SEND 11 hello")] >#> [("", "1", "ERROR SYNTAX 2")] it "no connection ID" $ [("123", "", "SEND :hello")] >#> [("", "", "ERROR SYNTAX 5")] it "bad message body" $ [("123", "1", "SEND hello")] >#> [("", "1", "ERROR SYNTAX 6")] - it "bigger body" $ [("123", "1", "SEND 4\nhello\n")] >#> [("", "1", "ERROR SYNTAX 7")] + it "bigger body" $ [("123", "1", "SEND 4\nhello\n")] >#> [("", "1", "ERROR SIZE")] describe "broker response not allowed" do it "OK" $ [("123", "1", "OK")] >#> [("", "1", "ERROR PROHIBITED")] where