mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-11 14:44:45 +00:00
5b39f51203
* example websockets server * example of ws client * type class TConnection for generic TCP/WebSockets implementation * support WebSockets transport * rename TConnection methods * revert runClient to not need transport arg * pass the list of ports and transports via SMP server config * remove TypeApplications * s/Transport/TProxy/, s/TConnection/Transport/ * fix server with multiple transports, make SMP client use WS transport with port 80 (TODO fallback to WS)
34 lines
973 B
Haskell
34 lines
973 B
Haskell
{-# LANGUAGE DuplicateRecordFields #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE TypeApplications #-}
|
|
|
|
module Main where
|
|
|
|
import Control.Logger.Simple
|
|
import qualified Data.List.NonEmpty as L
|
|
import Simplex.Messaging.Agent (runSMPAgent)
|
|
import Simplex.Messaging.Agent.Env.SQLite
|
|
import Simplex.Messaging.Client (smpDefaultConfig)
|
|
import Simplex.Messaging.Transport (TCP, Transport (..))
|
|
|
|
cfg :: AgentConfig
|
|
cfg =
|
|
AgentConfig
|
|
{ tcpPort = "5224",
|
|
smpServers = L.fromList ["localhost:5223#KXNE1m2E1m0lm92WGKet9CL6+lO742Vy5G6nsrkvgs8="],
|
|
rsaKeySize = 2048 `div` 8,
|
|
connIdBytes = 12,
|
|
tbqSize = 16,
|
|
dbFile = "smp-agent.db",
|
|
smpCfg = smpDefaultConfig
|
|
}
|
|
|
|
logCfg :: LogConfig
|
|
logCfg = LogConfig {lc_file = Nothing, lc_stderr = True}
|
|
|
|
main :: IO ()
|
|
main = do
|
|
putStrLn $ "SMP agent listening on port " ++ tcpPort (cfg :: AgentConfig)
|
|
setLogLevel LogInfo -- LogError
|
|
withGlobalLogging logCfg $ runSMPAgent (transport @TCP) cfg
|