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 }