当前位置: 首页>>代码示例>>Golang>>正文


Golang packet.Packet类代码示例

本文整理汇总了Golang中gslib/utils/packet.Packet的典型用法代码示例。如果您正苦于以下问题:Golang Packet类的具体用法?Golang Packet怎么用?Golang Packet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Packet类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: decodeEquipUnLoadResponse

func decodeEquipUnLoadResponse(buffer *packet.Packet) interface{} {
	data := &EquipUnLoadResponse{}
	data.PlayerID = buffer.ReadString()
	data.EquipId = buffer.ReadString()
	data.Level = buffer.ReadUint32()
	return data
}
开发者ID:HelloKevinTian,项目名称:golang_sample,代码行数:7,代码来源:decoder.go

示例2: decodeEquipUnLoadParams

func decodeEquipUnLoadParams(buffer *packet.Packet) interface{} {
	data := &EquipUnLoadParams{}
	data.PlayerID = buffer.ReadString()
	data.EquipId = buffer.ReadString()
	data.HeroId = buffer.ReadString()
	return data
}
开发者ID:HelloKevinTian,项目名称:golang_sample,代码行数:7,代码来源:decoder.go

示例3: decodeLoginResponse

func decodeLoginResponse(buffer *packet.Packet) interface{} {
	data := &LoginResponse{}
	data.Uuid = buffer.ReadString()
	data.Level = buffer.ReadUint32()
	data.Exp = buffer.ReadFloat32()

	for i := 0; i < int(buffer.ReadUint16()); i++ {
		data.Equips = append(data.Equips, decodeEquipLoadResponse(buffer).(*EquipLoadResponse))
	}

	for i := 0; i < int(buffer.ReadUint16()); i++ {
		data.Friends = append(data.Friends, buffer.ReadString())
	}

	for i := 0; i < int(buffer.ReadUint16()); i++ {
		data.Ages = append(data.Ages, buffer.ReadInt32())
	}
	return data
}
开发者ID:HelloKevinTian,项目名称:golang_sample,代码行数:19,代码来源:decoder.go

示例4: encodeLoginResponse

func encodeLoginResponse(buffer *packet.Packet, value interface{}) {
	v := value.(*LoginResponse)
	buffer.WriteString(v.Uuid)
	buffer.WriteUint32(v.Level)
	buffer.WriteFloat32(v.Exp)

	buffer.WriteUint16(uint16(len(v.Equips)))
	for i := 0; i < len(v.Equips); i++ {
		encodeEquipLoadResponse(buffer, v.Equips[i])
	}

	buffer.WriteUint16(uint16(len(v.Friends)))
	for i := 0; i < len(v.Friends); i++ {
		buffer.WriteString(v.Friends[i])
	}

	buffer.WriteUint16(uint16(len(v.Ages)))
	for i := 0; i < len(v.Ages); i++ {
		buffer.WriteInt32(v.Ages[i])
	}
}
开发者ID:HelloKevinTian,项目名称:golang_sample,代码行数:21,代码来源:encoder.go

示例5: encodeEquipUnLoadResponse

func encodeEquipUnLoadResponse(buffer *packet.Packet, value interface{}) {
	v := value.(*EquipUnLoadResponse)
	buffer.WriteString(v.PlayerID)
	buffer.WriteString(v.EquipId)
	buffer.WriteUint32(v.Level)
}
开发者ID:HelloKevinTian,项目名称:golang_sample,代码行数:6,代码来源:encoder.go

示例6: encodeEquipUnLoadParams

func encodeEquipUnLoadParams(buffer *packet.Packet, value interface{}) {
	v := value.(*EquipUnLoadParams)
	buffer.WriteString(v.PlayerID)
	buffer.WriteString(v.EquipId)
	buffer.WriteString(v.HeroId)
}
开发者ID:HelloKevinTian,项目名称:golang_sample,代码行数:6,代码来源:encoder.go


注:本文中的gslib/utils/packet.Packet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。