2013-08-29 16:51:23 +08:00
|
|
|
package client
|
|
|
|
|
|
|
|
const (
|
2013-12-26 15:28:42 +08:00
|
|
|
Network = "tcp"
|
2013-08-29 16:51:23 +08:00
|
|
|
// queue size
|
2013-12-26 15:28:42 +08:00
|
|
|
queueSize = 8
|
2013-08-29 16:51:23 +08:00
|
|
|
// read buffer size
|
2014-08-18 22:51:33 +08:00
|
|
|
bufferSize = 8192
|
2013-08-29 16:51:23 +08:00
|
|
|
// min packet length
|
2013-12-26 15:28:42 +08:00
|
|
|
minPacketLength = 12
|
2013-08-29 16:51:23 +08:00
|
|
|
|
|
|
|
// \x00REQ
|
2013-12-26 15:28:42 +08:00
|
|
|
req = 5391697
|
|
|
|
reqStr = "\x00REQ"
|
2013-08-29 16:51:23 +08:00
|
|
|
// \x00RES
|
2013-12-26 15:28:42 +08:00
|
|
|
res = 5391699
|
|
|
|
resStr = "\x00RES"
|
2013-08-29 16:51:23 +08:00
|
|
|
|
|
|
|
// package data type
|
2013-12-26 15:28:42 +08:00
|
|
|
dtCanDo = 1
|
|
|
|
dtCantDo = 2
|
|
|
|
dtResetAbilities = 3
|
|
|
|
dtPreSleep = 4
|
|
|
|
dtNoop = 6
|
|
|
|
dtJobCreated = 8
|
|
|
|
dtGrabJob = 9
|
|
|
|
dtNoJob = 10
|
|
|
|
dtJobAssign = 11
|
|
|
|
dtWorkStatus = 12
|
|
|
|
dtWorkComplete = 13
|
|
|
|
dtWorkFail = 14
|
|
|
|
dtGetStatus = 15
|
|
|
|
dtEchoReq = 16
|
|
|
|
dtEchoRes = 17
|
|
|
|
dtError = 19
|
|
|
|
dtStatusRes = 20
|
|
|
|
dtSetClientId = 22
|
|
|
|
dtCanDoTimeout = 23
|
|
|
|
dtAllYours = 24
|
|
|
|
dtWorkException = 25
|
|
|
|
dtWorkData = 28
|
|
|
|
dtWorkWarning = 29
|
|
|
|
dtGrabJobUniq = 30
|
|
|
|
dtJobAssignUniq = 31
|
2013-08-29 16:51:23 +08:00
|
|
|
|
2013-12-26 15:28:42 +08:00
|
|
|
dtSubmitJob = 7
|
|
|
|
dtSubmitJobBg = 18
|
|
|
|
dtSubmitJobHigh = 21
|
|
|
|
dtSubmitJobHighBg = 32
|
|
|
|
dtSubmitJobLow = 33
|
|
|
|
dtSubmitJobLowBg = 34
|
2014-01-09 16:16:34 +08:00
|
|
|
|
2014-01-09 17:58:02 +08:00
|
|
|
WorkComplate = dtWorkComplete
|
2017-09-27 13:19:08 +08:00
|
|
|
WorkComplete = dtWorkComplete
|
2014-01-15 09:40:36 +08:00
|
|
|
WorkData = dtWorkData
|
2014-01-09 17:58:02 +08:00
|
|
|
WorkStatus = dtWorkStatus
|
|
|
|
WorkWarning = dtWorkWarning
|
|
|
|
WorkFail = dtWorkFail
|
2014-01-09 16:16:34 +08:00
|
|
|
WorkException = dtWorkException
|
2013-08-29 16:51:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Job type
|
2014-01-09 16:16:34 +08:00
|
|
|
JobNormal = iota
|
2013-08-29 16:51:23 +08:00
|
|
|
// low level
|
2014-01-09 16:16:34 +08:00
|
|
|
JobLow
|
2013-08-29 16:51:23 +08:00
|
|
|
// high level
|
2014-01-09 16:16:34 +08:00
|
|
|
JobHigh
|
2013-08-29 16:51:23 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func getBuffer(l int) (buf []byte) {
|
|
|
|
// TODO add byte buffer pool
|
|
|
|
buf = make([]byte, l)
|
|
|
|
return
|
|
|
|
}
|