本文整理匯總了Golang中github.com/giskook/gotcp.Conn.SetID方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.SetID方法的具體用法?Golang Conn.SetID怎麽用?Golang Conn.SetID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/giskook/gotcp.Conn
的用法示例。
在下文中一共展示了Conn.SetID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: OnMessage
func (this *DasCallback) OnMessage(c *gotcp.Conn, p gotcp.Packet) bool {
// 0xBA command feedback 0xBB heartbeat 0xBC login
// 0xBA cmdtype(1-8) status(0/1) serialid
daspacket := p.(*DasPacket)
command := daspacket.GetData()
commandtype := daspacket.GetType()
fmt.Println("----onmessage ", command)
switch commandtype {
case 0xBA:
var result []byte
var cmdop byte
cmdop = command[0]*10 + command[1]
result = append(result, cmdop)
result = append(result, c.GetMac()...)
result = append(result, command[3:7]...)
result = append(result, command[2])
c.Send(c.GetTopic(), result)
fmt.Printf("-----recv should up the result%x \n", result)
case 0xBB:
c.SetTimeFlag(time.Now().Unix())
c.AsyncWritePacket(NewDasPacket(0xAB, command), time.Second)
case 0xBC:
c.SetID(getMac(command), c.GetIndex())
c.AsyncWritePacket(NewDasPacket(0xAC, command), time.Second)
default:
gktoolkit.Trace()
}
return true
}