-
Notifications
You must be signed in to change notification settings - Fork 35
/
msg.go
94 lines (78 loc) · 2.14 KB
/
msg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package msg
const (
TypeRegisterWorker = 'a'
TypeRegisterWorkerResp = 'b'
TypeSendFile = 'c'
TypeSendFileResp = 'd'
TypeReceiveFile = 'e'
TypeReceiveFileResp = 'f'
TypeNewSendFileStream = 'g'
TypeNewSendFileStreamResp = 'h'
TypeNewReceiveFileStream = 'i'
TypeNewReceiveFileStreamResp = 'j'
TypePing = 'y'
TypePong = 'z'
)
var (
msgTypeMap = map[byte]interface{}{
TypeRegisterWorker: RegisterWorker{},
TypeRegisterWorkerResp: RegisterWorkerResp{},
TypeSendFile: SendFile{},
TypeSendFileResp: SendFileResp{},
TypeReceiveFile: ReceiveFile{},
TypeReceiveFileResp: ReceiveFileResp{},
TypeNewSendFileStream: NewSendFileStream{},
TypeNewSendFileStreamResp: NewSendFileStreamResp{},
TypeNewReceiveFileStream: NewReceiveFileStream{},
TypeNewReceiveFileStreamResp: NewReceiveFileStreamResp{},
TypePing: Ping{},
TypePong: Pong{},
}
)
type RegisterWorker struct {
Version string `json:"version"`
BindPort int64 `json:"bind_port"`
PublicIP string `json:"public_ip"`
}
type RegisterWorkerResp struct {
Error string `json:"error"`
}
type SendFile struct {
ID string `json:"id"`
Fsize int64 `json:"fsize"`
Name string `json:"name"`
CacheCount int64 `json:"cache_count"`
}
type SendFileResp struct {
ID string `json:"id"`
Workers []string `json:"workers"`
CacheCount int64 `json:"cache_count"`
Error string `json:"error"`
}
type ReceiveFile struct {
ID string `json:"id"`
CacheCount int64 `json:"cache_count"`
}
type ReceiveFileResp struct {
Name string `json:"name"`
Fsize int64 `json:"fsize"`
Workers []string `json:"workers"`
CacheCount int64 `json:"cache_count"`
Error string `json:"error"`
}
type NewSendFileStream struct {
ID string `json:"id"`
}
type NewSendFileStreamResp struct {
Error string `json:"error"`
}
type NewReceiveFileStream struct {
ID string `json:"id"`
}
type NewReceiveFileStreamResp struct {
Error string `json:"error"`
}
type Ping struct {
}
type Pong struct {
}