mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-28 23:36:03 +00:00
1.8 KiB
1.8 KiB
Sending small files
Problem
Sending files has a substantial constant overhead, and requires multiple online presenses from both sides, with additional connection handshake. For large files this overhead is justified, as otherwise files would consume queue quota, but for small files it makes sending files slow.
Solution
Send small files in the same connection. There can be two modes of sending files - the one that requires explicit acceptance, but after the acceptance the file will be delivered inline, without creating a new conneciton. Another, when the file will be sent straight after the message - that would require preliminary agreement, per contact - this mode can be useful for small voice messages and gifs.
Design
- Add optional
fileInline :: Maybe FileInlineModeproperty toFileInvitation:
data FileInlineMode
= FIInvitation -- recepient must accept
| FIChunks -- file is sent after the message without acceptance
- Add
XFileAcptInline SharedMsgId Stringmessage to accept inline files, this can only be sent in case inline mode is offered, so the sender would support it:
{
"properties": {
"type": {"enum": ["x.file.acpt.inline"]},
"msgId": {"ref": "base64url"},
"params": {
"properties": {
"msgId": {"ref": "base64url"},
"fileName": {"type": "string"}
}
}
}
}
- Add
XFileChunksmessage that have to be sent in front of the sequence of chunks (sent only inFIInvitationmode):
{
"properties": {
"type": {"enum": ["x.file.chunks"]},
"msgId": {"ref": "base64url"},
"params": {
"properties": {
"msgId": {"ref": "base64url"},
"fileName": {"type": "string"}
}
}
}
}
- Support file chunks in the main connection if the previous message was
XFileChunksorFileInvitationinFIChunksmode.