mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-15 03:05:08 +00:00
SMP agent: data types for connections and message delivery
This commit is contained in:
+1
-1
@@ -104,4 +104,4 @@ digraph SMPAgent {
|
||||
|
||||
uAgent -> runClient [style=dashed label="fork" color=orange fontcolor=orange]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import Control.Monad.IO.Class
|
||||
import Data.ByteString.Char8 (ByteString)
|
||||
import qualified Data.ByteString.Char8 as B
|
||||
import Data.Kind
|
||||
import Data.Time.Clock
|
||||
import Data.Time.Clock (UTCTime)
|
||||
import Network.Socket
|
||||
import Simplex.Messaging.Server.Transmission (Encoded, MsgBody, PublicKey, QueueId)
|
||||
import Simplex.Messaging.Transport
|
||||
@@ -40,7 +40,7 @@ data ACommand (a :: AParty) where
|
||||
SUB :: ConnAlias -> SubMode -> ACommand User
|
||||
END :: ConnAlias -> ACommand Agent
|
||||
QST :: ConnAlias -> QueueDirection -> ACommand User
|
||||
STAT :: ConnAlias -> QueueDirection -> Maybe ConnState -> Maybe SubMode -> ACommand Agent
|
||||
STAT :: ConnAlias -> QueueDirection -> Maybe QueueState -> Maybe SubMode -> ACommand Agent
|
||||
SEND :: ConnAlias -> MsgBody -> ACommand User
|
||||
MSG :: ConnAlias -> AgentMsgId -> UTCTime -> UTCTime -> MsgStatus -> MsgBody -> ACommand Agent
|
||||
ACK :: ConnAlias -> AgentMsgId -> ACommand User
|
||||
@@ -84,7 +84,7 @@ type VerificationKey = PublicKey
|
||||
|
||||
data QueueDirection = SND | RCV deriving (Show)
|
||||
|
||||
data ConnState = New | Pending | Confirmed | Secured | Active | Disabled
|
||||
data QueueState = New | Confirmed | Secured | Active | Disabled
|
||||
deriving (Show)
|
||||
|
||||
type AgentMsgId = Int
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
|
||||
module Simplex.Messaging.Agent.ConnStore where
|
||||
|
||||
import Data.Time.Clock (UTCTime)
|
||||
import Simplex.Messaging.Agent.Command
|
||||
import Simplex.Messaging.Server.Transmission (Encoded, PublicKey, QueueId)
|
||||
|
||||
data ReceiveQueue = ReceiveQueue
|
||||
{ server :: SMPServer,
|
||||
rcvId :: QueueId,
|
||||
rcvPrivateKey :: PrivateKey,
|
||||
sndId :: Maybe QueueId,
|
||||
sndKey :: Maybe PublicKey,
|
||||
decryptKey :: PrivateKey,
|
||||
verifyKey :: Maybe PublicKey,
|
||||
status :: QueueState,
|
||||
ackMode :: AckMode
|
||||
}
|
||||
|
||||
data SendQueue = SendQueue
|
||||
{ server :: SMPServer,
|
||||
sndId :: QueueId,
|
||||
sndPrivateKey :: PrivateKey,
|
||||
encryptKey :: PublicKey,
|
||||
signKey :: PrivateKey,
|
||||
status :: QueueState,
|
||||
ackMode :: AckMode
|
||||
}
|
||||
|
||||
data Connection
|
||||
= ReceiveConnection {connAlias :: ConnAlias, rcvQueue :: ReceiveQueue}
|
||||
| SendConnection {connAlias :: ConnAlias, sndQueue :: SendQueue}
|
||||
| DuplexConnection {connAlias :: ConnAlias, rcvQueue :: ReceiveQueue, sndQueue :: SendQueue}
|
||||
|
||||
data MessageDelivery = MessageDelivery
|
||||
{ connAlias :: ConnAlias,
|
||||
agentMsgId :: Int,
|
||||
timestamp :: UTCTime,
|
||||
message :: AMessage,
|
||||
direction :: QueueDirection,
|
||||
msgStatus :: DeliveryStatus
|
||||
}
|
||||
|
||||
type PrivateKey = Encoded
|
||||
|
||||
data DeliveryStatus
|
||||
= MDTransmitted -- SMP: SEND sent / MSG received
|
||||
| MDConfirmed -- SMP: OK received / ACK sent
|
||||
| MDAcknowledged -- SAMP: RCVD sent to agent client / ACK received from agent client and sent to the server
|
||||
Reference in New Issue
Block a user