當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。