本文整理匯總了Golang中github.com/grayzone/devicemonitor/conn.Setting.Sessionkey方法的典型用法代碼示例。如果您正苦於以下問題:Golang Setting.Sessionkey方法的具體用法?Golang Setting.Sessionkey怎麽用?Golang Setting.Sessionkey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/grayzone/devicemonitor/conn.Setting
的用法示例。
在下文中一共展示了Setting.Sessionkey方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: worker
func worker(t time.Duration) {
for {
time.Sleep(time.Millisecond * t)
// log.Println("working....")
var m conn.Message
err := m.GetOneResponse()
if err != nil {
// log.Println("worker:", err.Error())
continue
// log.Printf("get one response :%v", m)
}
// log.Println(m.Info)
b, err := hex.DecodeString(m.Info)
if err != nil {
log.Println(err.Error())
m.Status = conn.INVALID
m.UpdateStatus()
continue
}
var f ftprotocol.Frame
// log.Printf("%X", b)
s, err := f.Parse(b)
if err != nil {
log.Printf("%X:%s\n", b, err.Error())
// m.DeleteMessage()
m.Status = conn.INVALID
m.UpdateStatus()
continue
}
msgid, _ := strconv.ParseInt(string(f.MessageID), 16, 32)
switch msgid {
case ftprotocol.REQUESTSESSIONRESPONSE:
var sessionres ftprotocol.RequestSessionResponse
sessionres.Frame = f
err := sessionres.ParseMessageData(f.MessageData)
if err != nil {
log.Println(err.Error())
m.Status = conn.INVALID
m.UpdateStatus()
continue
}
var s conn.Setting
s.Sessionstatus = sessionres.SessionStatus
s.UpdateSessionStatus()
s.Sessiontimeout = sessionres.SessionTimeout
s.UpdateSessiontimeout()
s.Deviceid = conn.DeviceID(sessionres.DeviceID)
s.UpdateDeviceid()
s.Protocolver = strconv.FormatUint(uint64(sessionres.ProtocolVersion), 10)
s.UpdateProtocolVer()
s.Sessionkey = string(sessionres.SessionKey)
s.UpdateSessionKey()
s.Sequence = string(sessionres.Sequence)
s.UpdateSequence()
s.Messagetimeout = sessionres.MessageTimeout
s.UpdateMessagetimeout()
s.Maxretrycount = sessionres.MaxRetryCount
s.UpdateMaxretrycount()
case ftprotocol.DEVICENAMERESPONSE:
var res ftprotocol.DeviceNameResponse
res.Frame = f
err := res.ParseMessageData(f.MessageData)
if err != nil {
log.Println(err.Error())
m.Status = conn.INVALID
m.UpdateStatus()
continue
}
var s conn.Setting
// log.Println("device name : ", res.StringName)
s.Devicename = res.StringName
err = s.UpdateDevicename()
if err != nil {
log.Println("UpdateDevicename:", err.Error())
}
case ftprotocol.GETSENSORRESPONSE:
var res ftprotocol.GetSensorResponse
res.Frame = f
err := res.ParseMessageData(f.MessageData)
if err != nil {
log.Println("GETSENSORRESPONSE:", err.Error())
m.Status = conn.INVALID
m.UpdateStatus()
//.........這裏部分代碼省略.........