mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-22 19:57:20 +00:00
simplex-chat server & JavaScript/TypeScript SDK/client (#539)
* simplex-chat server * typescript types for chat commands and command serialization * typescript ChatResponse type * more types * more types * websocket chat client * aligb ts/haskell types * chat server & TS client via websockets - it works * TS chat client test * TS chat client test * update test * more api functions * more api methods, refactor, readme * squaring chat bot example, fixes * update readme * remove console.log * npm version 0.1.0
This commit is contained in:
committed by
GitHub
parent
9f5ea49676
commit
b7860ad0e8
@@ -53,7 +53,8 @@ mobileChatOpts =
|
||||
logConnections = False,
|
||||
logAgent = False,
|
||||
chatCmd = "",
|
||||
chatCmdDelay = 3
|
||||
chatCmdDelay = 3,
|
||||
chatServerPort = Nothing
|
||||
}
|
||||
|
||||
defaultMobileConfig :: ChatConfig
|
||||
|
||||
@@ -24,7 +24,8 @@ data ChatOpts = ChatOpts
|
||||
logConnections :: Bool,
|
||||
logAgent :: Bool,
|
||||
chatCmd :: String,
|
||||
chatCmdDelay :: Int
|
||||
chatCmdDelay :: Int,
|
||||
chatServerPort :: Maybe String
|
||||
}
|
||||
|
||||
chatOpts :: FilePath -> FilePath -> Parser ChatOpts
|
||||
@@ -78,13 +79,28 @@ chatOpts appDir defaultDbFileName = do
|
||||
<> value 3
|
||||
<> showDefault
|
||||
)
|
||||
pure ChatOpts {dbFilePrefix, smpServers, logConnections, logAgent, chatCmd, chatCmdDelay}
|
||||
chatServerPort <-
|
||||
option
|
||||
parseServerPort
|
||||
( long "chat-server-port"
|
||||
<> short 'p'
|
||||
<> metavar "PORT"
|
||||
<> help "Run chat server on specified port"
|
||||
<> value Nothing
|
||||
)
|
||||
pure ChatOpts {dbFilePrefix, smpServers, logConnections, logAgent, chatCmd, chatCmdDelay, chatServerPort}
|
||||
where
|
||||
defaultDbFilePath = combine appDir defaultDbFileName
|
||||
|
||||
parseSMPServers :: ReadM [SMPServer]
|
||||
parseSMPServers = eitherReader $ parseAll smpServersP . B.pack
|
||||
|
||||
parseServerPort :: ReadM (Maybe String)
|
||||
parseServerPort = eitherReader $ parseAll serverPortP . B.pack
|
||||
|
||||
serverPortP :: A.Parser (Maybe String)
|
||||
serverPortP = Just . B.unpack <$> A.takeWhile A.isDigit
|
||||
|
||||
smpServersP :: A.Parser [SMPServer]
|
||||
smpServersP = strP `A.sepBy1` A.char ','
|
||||
|
||||
|
||||
Reference in New Issue
Block a user