• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang packet.ReadUint16函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Decode

func (this *packetClientLoginEncryptRequestCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientLoginEncryptRequest := new(PacketClientLoginEncryptRequest)
	packetClientLoginEncryptRequest.ServerId, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	publicKeyLength, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.PublicKey = make([]byte, publicKeyLength)
	_, err = reader.Read(packetClientLoginEncryptRequest.PublicKey)
	if err != nil {
		return
	}
	verifyTokenLength, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.VerifyToken = make([]byte, verifyTokenLength)
	_, err = reader.Read(packetClientLoginEncryptRequest.VerifyToken)
	if err != nil {
		return
	}
	decode = packetClientLoginEncryptRequest
	return
}
开发者ID:LivousCraftNetwork,项目名称:GoLilyPad,代码行数:27,代码来源:packetClientLoginEncryptRequest17.go


示例2: Decode

func (this *PacketClientLoginEncryptRequestCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientLoginEncryptRequest := &PacketClientLoginEncryptRequest{}
	packetClientLoginEncryptRequest.ServerId, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	publicKeySize, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.PublicKey = make([]byte, publicKeySize)
	_, err = reader.Read(packetClientLoginEncryptRequest.PublicKey)
	if err != nil {
		return
	}
	verifyTokenSize, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetClientLoginEncryptRequest.VerifyToken = make([]byte, verifyTokenSize)
	_, err = reader.Read(packetClientLoginEncryptRequest.VerifyToken)
	if err != nil {
		return
	}
	return packetClientLoginEncryptRequest, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:26,代码来源:packetClientLoginEncryptRequest.go


示例3: Decode

func (this *requestAsProxyCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestAsProxy := new(RequestAsProxy)
	requestAsProxy.Address, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.Port, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.Motd, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.Version, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsProxy.MaxPlayers, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	request = requestAsProxy
	return
}
开发者ID:LivousCraftNetwork,项目名称:GoLilyPad,代码行数:25,代码来源:requestAsProxy.go


示例4: Decode

func (this *requestMessageCodec) Decode(reader io.Reader) (request Request, err error) {
	requestMessage := new(RequestMessage)
	recipientsSize, err := packet.ReadUint16(reader)
	if err != nil {
		return
	}
	requestMessage.Recipients = make([]string, recipientsSize)
	var i uint16
	for i = 0; i < recipientsSize; i++ {
		requestMessage.Recipients[i], err = packet.ReadString(reader)
		if err != nil {
			return
		}
	}
	requestMessage.Channel, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	messageSize, err := packet.ReadUint16(reader)
	if err != nil {
		return
	}
	requestMessage.Message = make([]byte, messageSize)
	_, err = reader.Read(requestMessage.Message)
	if err != nil {
		return
	}
	request = requestMessage
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:30,代码来源:requestMessage.go


示例5: Decode

func (this *ResultGetPlayersCodec) Decode(reader io.Reader, util []byte) (result Result, err error) {
	resultGetPlayers := &ResultGetPlayers{}
	resultGetPlayers.List, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	resultGetPlayers.CurrentPlayers, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	resultGetPlayers.MaximumPlayers, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	if resultGetPlayers.List {
		resultGetPlayers.Players = make([]string, resultGetPlayers.CurrentPlayers)
		var i uint16
		for i = 0; i < resultGetPlayers.CurrentPlayers; i++ {
			if err != nil {
				return
			}
			resultGetPlayers.Players[i], err = packet.ReadString(reader, util)
		}
	}
	return resultGetPlayers, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:26,代码来源:requestGetPlayers.go


示例6: Decode

func (this *resultGetPlayersCodec) Decode(reader io.Reader) (result Result, err error) {
	resultGetPlayers := new(ResultGetPlayers)
	resultGetPlayers.List, err = packet.ReadBool(reader)
	if err != nil {
		return
	}
	resultGetPlayers.CurrentPlayers, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	resultGetPlayers.MaxPlayers, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	if resultGetPlayers.List {
		resultGetPlayers.Players = make([]string, resultGetPlayers.CurrentPlayers)
		var i uint16
		for i = 0; i < resultGetPlayers.CurrentPlayers; i++ {
			if err != nil {
				return
			}
			resultGetPlayers.Players[i], err = packet.ReadString(reader)
		}
	}
	result = resultGetPlayers
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:27,代码来源:requestGetPlayers.go


示例7: Decode

func (this *packetServerEventCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetServerEvent := new(PacketServerEvent)
	packetServerEvent.Add, err = packet.ReadBool(reader)
	if err != nil {
		return
	}
	packetServerEvent.Server, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	if packetServerEvent.Add {
		packetServerEvent.SecurityKey, err = packet.ReadString(reader)
		if err != nil {
			return
		}
		packetServerEvent.Address, err = packet.ReadString(reader)
		if err != nil {
			return
		}
		packetServerEvent.Port, err = packet.ReadUint16(reader)
		if err != nil {
			return
		}
	}
	decode = packetServerEvent
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:27,代码来源:packetServerEvent.go


示例8: Decode

func (this *PacketServerEventCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerEvent := &PacketServerEvent{}
	packetServerEvent.Add, err = packet.ReadBool(reader, util)
	if err != nil {
		return
	}
	packetServerEvent.Server, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	if packetServerEvent.Add {
		packetServerEvent.SecurityKey, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetServerEvent.Address, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetServerEvent.Port, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
	}
	return packetServerEvent, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:26,代码来源:packetServerEvent.go


示例9: Decode

func (this *RequestAsServerCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestAsServer := &RequestAsServer{}
	requestAsServer.Address, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAsServer.Port, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	return requestAsServer, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:12,代码来源:requestAsServer.go


示例10: Decode

func (this *PacketServerLoginEncryptResponseCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerLoginEncryptResponse := &PacketServerLoginEncryptResponse{}
	sharedSecretSize, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetServerLoginEncryptResponse.SharedSecret = make([]byte, sharedSecretSize)
	_, err = reader.Read(packetServerLoginEncryptResponse.SharedSecret)
	if err != nil {
		return
	}
	verifyTokenSize, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetServerLoginEncryptResponse.VerifyToken = make([]byte, verifyTokenSize)
	_, err = reader.Read(packetServerLoginEncryptResponse.VerifyToken)
	if err != nil {
		return
	}
	return packetServerLoginEncryptResponse, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:22,代码来源:packetServerLoginEncryptResponse.go


示例11: Decode

func (this *requestAsServerCodec) Decode(reader io.Reader) (request Request, err error) {
	requestAsServer := new(RequestAsServer)
	requestAsServer.Address, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	requestAsServer.Port, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	request = requestAsServer
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:13,代码来源:requestAsServer.go


示例12: Decode

func (this *packetServerLoginEncryptResponseCodec17) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetServerLoginEncryptResponse := new(PacketServerLoginEncryptResponse)
	sharedSecretLength, err := packet.ReadUint16(reader)
	if err != nil {
		return
	}
	packetServerLoginEncryptResponse.SharedSecret = make([]byte, sharedSecretLength)
	_, err = reader.Read(packetServerLoginEncryptResponse.SharedSecret)
	if err != nil {
		return
	}
	verifyTokenLength, err := packet.ReadUint16(reader)
	if err != nil {
		return
	}
	packetServerLoginEncryptResponse.VerifyToken = make([]byte, verifyTokenLength)
	_, err = reader.Read(packetServerLoginEncryptResponse.VerifyToken)
	if err != nil {
		return
	}
	decode = packetServerLoginEncryptResponse
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:23,代码来源:packetServerLoginEncryptResponse17.go


示例13: Decode

func (this *packetResultCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	if this.Sequencer == nil {
		err = errors.New("No sequencer to decode PacketResult")
		return
	}
	packetResult := new(PacketResult)
	packetResult.SequenceId, err = packet.ReadInt32(reader)
	if err != nil {
		return
	}
	packetResult.StatusCode, err = packet.ReadUint8(reader)
	if err != nil {
		return
	}
	if packetResult.StatusCode == STATUS_SUCCESS {
		var payloadSize uint16
		payloadSize, err = packet.ReadUint16(reader)
		if err != nil {
			return
		}
		payload := make([]byte, payloadSize)
		_, err = reader.Read(payload)
		if err != nil {
			return
		}
		buffer := bytes.NewBuffer(payload)
		requestId := this.Sequencer.RequestIdBySequenceId(packetResult.SequenceId)
		if requestId < 0 {
			err = errors.New(fmt.Sprintf("Decode, Request Id is below zero: %d", requestId))
			return
		}
		if int(requestId) >= len(requestCodecs) {
			err = errors.New(fmt.Sprintf("Decode, Request Id is above maximum: %d", requestId))
			return
		}
		codec := resultCodecs[requestId]
		if codec == nil {
			err = errors.New(fmt.Sprintf("Decode, Request Id does not have a codec: %d", requestId))
			return
		}
		packetResult.Result, err = codec.Decode(buffer)
		if err != nil {
			return
		}
	}
	decode = packetResult
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:48,代码来源:packetResult.go


示例14: Decode

func (this *packetClientTeamsCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientTeams := new(PacketClientTeams)
	packetClientTeams.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientTeams.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 2 {
		packetClientTeams.DisplayName, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Prefix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Suffix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.FriendlyFire, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 3 || packetClientTeams.Action == 4 {
		var playersLength uint16
		playersLength, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Players = make([]string, playersLength)
		var i uint16
		for i = 0; i < playersLength; i++ {
			packetClientTeams.Players[i], err = packet.ReadString(reader, util)
			if err != nil {
				return
			}
		}
	}
	decode = packetClientTeams
	return
}
开发者ID:LivousCraftNetwork,项目名称:GoLilyPad,代码行数:46,代码来源:packetClientTeams17.go


示例15: Decode

func (this *PacketClientTeamsCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientTeams := &PacketClientTeams{}
	packetClientTeams.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientTeams.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 2 {
		packetClientTeams.DisplayName, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Prefix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Suffix, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.FriendlyFire, err = packet.ReadInt8(reader, util)
		if err != nil {
			return
		}
	}
	if packetClientTeams.Action == 0 || packetClientTeams.Action == 3 || packetClientTeams.Action == 4 {
		var playersSize uint16
		playersSize, err = packet.ReadUint16(reader, util)
		if err != nil {
			return
		}
		packetClientTeams.Players = make([]string, playersSize)
		var i uint16
		for i = 0; i < playersSize; i++ {
			packetClientTeams.Players[i], err = packet.ReadString(reader, util)
			if err != nil {
				return
			}
		}
	}
	return packetClientTeams, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:45,代码来源:packetClientTeams.go


示例16: Decode

func (this *packetServerPluginMessageCodec17) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerPluginMessage := new(PacketServerPluginMessage)
	packetServerPluginMessage.Channel, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	dataLength, err := packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetServerPluginMessage.Data = make([]byte, dataLength)
	_, err = reader.Read(packetServerPluginMessage.Data)
	if err != nil {
		return
	}
	decode = packetServerPluginMessage
	return
}
开发者ID:LivousCraftNetwork,项目名称:GoLilyPad,代码行数:18,代码来源:packetServerPluginMessage17.go


示例17: Decode

func (this *ResultGetDetailsCodec) Decode(reader io.Reader, util []byte) (result Result, err error) {
	resultGetDetails := &ResultGetDetails{}
	resultGetDetails.Ip, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	resultGetDetails.Port, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	resultGetDetails.Motd, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	resultGetDetails.Version, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return resultGetDetails, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:20,代码来源:requestGetDetails.go


示例18: Decode

func (this *PacketServerHandshakeCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetServerHandshake := &PacketServerHandshake{}
	packetServerHandshake.ProtocolVersion, err = packet.ReadVarInt(reader, util)
	if err != nil {
		return
	}
	packetServerHandshake.ServerAddress, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetServerHandshake.ServerPort, err = packet.ReadUint16(reader, util)
	if err != nil {
		return
	}
	packetServerHandshake.State, err = packet.ReadVarInt(reader, util)
	if err != nil {
		return
	}
	return packetServerHandshake, nil
}
开发者ID:Jumla,项目名称:GoLilyPad,代码行数:20,代码来源:packetServerHandshake.go


示例19: Decode

func (this *packetServerHandshakeCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetServerHandshake := new(PacketServerHandshake)
	packetServerHandshake.ProtocolVersion, err = packet.ReadVarInt(reader)
	if err != nil {
		return
	}
	packetServerHandshake.ServerAddress, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetServerHandshake.ServerPort, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	packetServerHandshake.State, err = packet.ReadVarInt(reader)
	if err != nil {
		return
	}
	decode = packetServerHandshake
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:21,代码来源:packetServerHandshake.go


示例20: Decode

func (this *resultGetDetailsCodec) Decode(reader io.Reader) (result Result, err error) {
	resultGetDetails := new(ResultGetDetails)
	resultGetDetails.Ip, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	resultGetDetails.Port, err = packet.ReadUint16(reader)
	if err != nil {
		return
	}
	resultGetDetails.Motd, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	resultGetDetails.Version, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	result = resultGetDetails
	return
}
开发者ID:0xNiklas,项目名称:GoLilyPad,代码行数:21,代码来源:requestGetDetails.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang packet.WriteString函数代码示例发布时间:2022-05-23
下一篇:
Golang packet.ReadString函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap