當前位置: 首頁>>代碼示例>>Golang>>正文


Golang packet.ReadUint16函數代碼示例

本文整理匯總了Golang中github.com/LilyPad/GoLilyPad/packet.ReadUint16函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReadUint16函數的具體用法?Golang ReadUint16怎麽用?Golang ReadUint16使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ReadUint16函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的github.com/LilyPad/GoLilyPad/packet.ReadUint16函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。