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


Golang packet.ReadString函數代碼示例

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


在下文中一共展示了ReadString函數的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 *packetClientScoreboardObjectiveCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientScoreboardObjective := new(PacketClientScoreboardObjective)
	packetClientScoreboardObjective.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientScoreboardObjective.Action, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	switch packetClientScoreboardObjective.Action {
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_ADD:
		fallthrough
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_UPDATE:
		packetClientScoreboardObjective.Value, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
		packetClientScoreboardObjective.Type, err = packet.ReadString(reader, util)
		if err != nil {
			return
		}
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_REMOVE:
		// no payload
	default:
		err = errors.New(fmt.Sprintf("Decode, PacketClientScoreboardObjective action is not valid: %d", packetClientScoreboardObjective.Action))
	}
	decode = packetClientScoreboardObjective
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:30,代碼來源:packetClientScoreboardObjective.go

示例3: 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

示例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 *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

示例6: 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

示例7: Decode

func (this *RequestAuthenticateCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestAuthenticate := &RequestAuthenticate{}
	requestAuthenticate.Username, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestAuthenticate.Password, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return requestAuthenticate, nil
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:12,代碼來源:requestAuthenticate.go

示例8: Decode

func (this *PacketClientLoginSuccessCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientLoginSuccess := &PacketClientLoginSuccess{}
	packetClientLoginSuccess.UUID, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetClientLoginSuccess.Name, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientLoginSuccess, nil
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:12,代碼來源:packetClientLoginSuccess.go

示例9: Decode

func (this *PacketRedirectEventCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetRedirectEvent := &PacketRedirectEvent{}
	packetRedirectEvent.Server, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	packetRedirectEvent.Player, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetRedirectEvent, nil
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:12,代碼來源:packetRedirectEvent.go

示例10: Decode

func (this *RequestRedirectCodec) Decode(reader io.Reader, util []byte) (request Request, err error) {
	requestRedirect := &RequestRedirect{}
	requestRedirect.Server, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	requestRedirect.Player, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return requestRedirect, nil
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:12,代碼來源:requestRedirect.go

示例11: Decode

func (this *packetClientLoginSuccessCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetClientLoginSuccess := new(PacketClientLoginSuccess)
	packetClientLoginSuccess.UUID, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetClientLoginSuccess.Name, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	decode = packetClientLoginSuccess
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:13,代碼來源:packetClientLoginSuccess.go

示例12: Decode

func (this *packetRedirectEventCodec) Decode(reader io.Reader) (decode packet.Packet, err error) {
	packetRedirectEvent := new(PacketRedirectEvent)
	packetRedirectEvent.Server, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	packetRedirectEvent.Player, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	decode = packetRedirectEvent
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:13,代碼來源:packetRedirectEvent.go

示例13: Decode

func (this *requestAuthenticateCodec) Decode(reader io.Reader) (request Request, err error) {
	requestAuthenticate := new(RequestAuthenticate)
	requestAuthenticate.Username, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	requestAuthenticate.Password, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	request = requestAuthenticate
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:13,代碼來源:requestAuthenticate.go

示例14: Decode

func (this *requestRedirectCodec) Decode(reader io.Reader) (request Request, err error) {
	requestRedirect := new(RequestRedirect)
	requestRedirect.Server, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	requestRedirect.Player, err = packet.ReadString(reader)
	if err != nil {
		return
	}
	request = requestRedirect
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:13,代碼來源:requestRedirect.go

示例15: Decode

func (this *PacketClientJoinGameCodec) Decode(reader io.Reader, util []byte) (decode packet.Packet, err error) {
	packetClientJoinGame := &PacketClientJoinGame{}
	packetClientJoinGame.EntityId, err = packet.ReadInt32(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Gamemode, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Dimension, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.Difficulty, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.MaxPlayers, err = packet.ReadInt8(reader, util)
	if err != nil {
		return
	}
	packetClientJoinGame.LevelType, err = packet.ReadString(reader, util)
	if err != nil {
		return
	}
	return packetClientJoinGame, nil
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:28,代碼來源:packetClientJoinGame.go


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