Basics of receiving files

This commit is contained in:
2022-01-15 14:04:13 +10:30
parent 1e4ee09d5c
commit d90eab464d
4 changed files with 149 additions and 10 deletions

View File

@@ -178,6 +178,7 @@ type OperationTypeEnum byte
const (
OperationTypeSend OperationTypeEnum = iota
OperationTypeList
OperationTypeReceive
)
// PacketStart is sent from the client to the server at the beginning
@@ -193,6 +194,39 @@ type PacketSendDataStart struct {
Filename string
TotalSize uint32
}
type PacketSendDataNext struct {
Size uint16
Data []byte
}
// PacketReceiveDataStart is sent from the server to the client when
// the client asks for a file to be sent to them.
type PacketReceiveDataStartRequest struct {
Id uint32
}
type PacketReceiveDataStartResponseEnum byte
const (
// File transfer can begin
ReceiveDataStartResponseOK PacketReceiveDataStartResponseEnum = iota
// No such file by index
ReceiveDataStartResponseNotFound
)
// PacketReceiveDataStartResponse is the response to the above packet.
type PacketReceiveDataStartResponse struct {
Status PacketReceiveDataStartResponseEnum
Filename string
Kind string
TotalSize uint32
}
type PacketReceiveDataNext struct {
Size uint16
Data []byte
Last bool
}
type PacketListData struct {
Id uint32
@@ -200,8 +234,3 @@ type PacketListData struct {
FileSize uint32
Kind string
}
type PacketSendDataNext struct {
Size uint16
Data []byte
}