func do(packetId uint16, buf []byte) { println("packetId: ", packetId) packet := packet.NewReadBuff(buf) switch packetId { case proto.P_ACK_TEST_X_X: ackTestXX := proto.AckTestXXDecode(packet) fmt.Println(ackTestXX) default: fmt.Println("unknown packetId:", packetId) } }
func dispatch(packetId uint16, buf []byte) { println("packetId: ", packetId) packet := packet.NewReadBuff(buf) switch packetId { case proto.P_REQ_TEST_X_X: reqTestXX := proto.ReqTestXXDecode(packet) fmt.Println("reqTestXX:", reqTestXX) case proto.P_REQ_TEST_SEND: reqTestSend := proto.ReqTestSendDecode(packet) fmt.Println("reqTestXX:", reqTestSend) fmt.Println(reqTestSend.GetOpRoleBase().GetUid()) fmt.Println(reqTestSend.GetOpRoleBase().GetUname()) default: fmt.Println("unknown packetId:", packetId) } }