mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-07-03 06:51:53 +00:00
f3408d9bb6
* explicit exports * more empty exports * add exports * reorder * use correct ControlProtocol type for xftp router --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
41 lines
980 B
Haskell
41 lines
980 B
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Simplex.Messaging.Notifications.Server.Control
|
|
( ControlProtocol (..),
|
|
)
|
|
where
|
|
|
|
import qualified Data.Attoparsec.ByteString.Char8 as A
|
|
import Simplex.Messaging.Encoding.String
|
|
import Simplex.Messaging.Protocol (BasicAuth)
|
|
|
|
data ControlProtocol
|
|
= CPAuth BasicAuth
|
|
| CPStats
|
|
| CPStatsRTS
|
|
| CPServerInfo
|
|
| CPHelp
|
|
| CPQuit
|
|
| CPSkip
|
|
|
|
instance StrEncoding ControlProtocol where
|
|
strEncode = \case
|
|
CPAuth tok -> "auth " <> strEncode tok
|
|
CPStats -> "stats"
|
|
CPStatsRTS -> "stats-rts"
|
|
CPServerInfo -> "server-info"
|
|
CPHelp -> "help"
|
|
CPQuit -> "quit"
|
|
CPSkip -> ""
|
|
strP =
|
|
A.takeTill (== ' ') >>= \case
|
|
"auth" -> CPAuth <$> _strP
|
|
"stats" -> pure CPStats
|
|
"stats-rts" -> pure CPStatsRTS
|
|
"server-info" -> pure CPServerInfo
|
|
"help" -> pure CPHelp
|
|
"quit" -> pure CPQuit
|
|
"" -> pure CPSkip
|
|
_ -> fail "bad ControlProtocol command"
|