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:
Evgeny Poberezkin
2022-05-13 19:44:03 +01:00
committed by GitHub
parent 9f5ea49676
commit b7860ad0e8
29 changed files with 2563 additions and 9 deletions
+2 -1
View File
@@ -53,7 +53,8 @@ mobileChatOpts =
logConnections = False,
logAgent = False,
chatCmd = "",
chatCmdDelay = 3
chatCmdDelay = 3,
chatServerPort = Nothing
}
defaultMobileConfig :: ChatConfig
+18 -2
View File
@@ -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 ','