]> git.r.bdr.sh - rbdr/mobius/blame_incremental - hotline/transfer.go
Merge pull request #11 from jhalter/remove_placeholder_todo_file_comment
[rbdr/mobius] / hotline / transfer.go
... / ...
CommitLineData
1package hotline
2
3import (
4 "bytes"
5 "encoding/binary"
6 "errors"
7)
8
9type transfer struct {
10 Protocol [4]byte // "HTXF" 0x48545846
11 ReferenceNumber [4]byte // Unique ID generated for the transfer
12 DataSize [4]byte // File size
13 RSVD [4]byte // Not implemented in Hotline Protocol
14}
15
16var HTXF = [4]byte{0x48, 0x54, 0x58, 0x46} // (HTXF) is the only supported transfer protocol
17
18func (tf *transfer) Write(b []byte) (int, error) {
19 if err := binary.Read(bytes.NewReader(b), binary.BigEndian, tf); err != nil {
20 return 0, err
21 }
22
23 if tf.Protocol != HTXF {
24 return 0, errors.New("invalid protocol")
25 }
26
27 return len(b), nil
28}