-
-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chat message syntax, raw message type
- Loading branch information
1 parent
9ef5b87
commit b82a6af
Showing
4 changed files
with
52 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
module Simplex.Chat.Protocol where | ||
|
||
import Data.Aeson (Value) | ||
import Data.ByteString.Char8 (ByteString) | ||
import Data.Int (Int64) | ||
import Data.Text (Text) | ||
import Simplex.Messaging.Agent.Protocol | ||
import Simplex.Store.Types | ||
|
||
data ChatMessage = ChatMessage MsgMeta ChatMsgData | ||
type ChatTransmission = (MsgMeta, ChatMessage) | ||
|
||
data ChatMsgData = DirectChatMsg Contact ContentMsg | ||
data ChatMessage = DirectChatMsg Contact ContentMsg | ||
|
||
newtype ContentMsg = NewContentMsg ContentData | ||
|
||
newtype ContentData = ContentText Text | ||
|
||
data RawChatMessage = RawChatMessage | ||
{ chatMsgId :: Maybe Int64, | ||
chatMsgEvent :: ByteString, | ||
chatMsgParams :: [ByteString], | ||
chatMsgBody :: [(ContentType, MsgBodyPart)] | ||
} | ||
|
||
type ContentType = ByteString | ||
|
||
data MsgBodyPart | ||
= MBFull MsgPart | ||
| MBPartial MsgPart Int ByteString -- MsgPart in this constructor is only used to define type, it's content can (should?) be empty | ||
| MBEmpty | ||
|
||
data MsgPart = MsgPartBinary ByteString | MsgPartText Text | MsgPartJSON Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters