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


Golang packet.WriteString函數代碼示例

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


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

示例1: Encode

func (this *packetClientScoreboardObjectiveCodec) Encode(writer io.Writer, util []byte, encode packet.Packet) (err error) {
	packetClientScoreboardObjective := encode.(*PacketClientScoreboardObjective)
	err = packet.WriteString(writer, util, packetClientScoreboardObjective.Name)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, util, packetClientScoreboardObjective.Action)
	if err != nil {
		return
	}
	switch packetClientScoreboardObjective.Action {
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_ADD:
		fallthrough
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_UPDATE:
		err = packet.WriteString(writer, util, packetClientScoreboardObjective.Value)
		if err != nil {
			return
		}
		err = packet.WriteString(writer, util, packetClientScoreboardObjective.Type)
	case PACKET_CLIENT_SCOREBOARD_OBJECTIVE_ACTION_REMOVE:
		// no payload
	default:
		err = errors.New(fmt.Sprintf("Encode, PacketClientScoreboardObjective action is not valid: %d", packetClientScoreboardObjective.Action))
	}
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:26,代碼來源:packetClientScoreboardObjective.go

示例2: Encode

func (this *PacketRedirectEventCodec) Encode(writer io.Writer, util []byte, encode packet.Packet) (err error) {
	packetRedirectEvent := encode.(*PacketRedirectEvent)
	err = packet.WriteString(writer, util, packetRedirectEvent.Server)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, util, packetRedirectEvent.Player)
	return
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:9,代碼來源:packetRedirectEvent.go

示例3: Encode

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

示例4: Encode

func (this *packetClientLoginSuccessCodec) Encode(writer io.Writer, encode packet.Packet) (err error) {
	packetClientLoginSuccess := encode.(*PacketClientLoginSuccess)
	err = packet.WriteString(writer, packetClientLoginSuccess.UUID)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, packetClientLoginSuccess.Name)
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:9,代碼來源:packetClientLoginSuccess.go

示例5: Encode

func (this *requestRedirectCodec) Encode(writer io.Writer, util []byte, request Request) (err error) {
	requestRedirect := request.(*RequestRedirect)
	err = packet.WriteString(writer, util, requestRedirect.Server)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, util, requestRedirect.Player)
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:9,代碼來源:requestRedirect.go

示例6: Encode

func (this *packetClientScoreboardObjectiveCodec17) Encode(writer io.Writer, encode packet.Packet) (err error) {
	packetClientScoreboardObjective := encode.(*PacketClientScoreboardObjective)
	err = packet.WriteString(writer, packetClientScoreboardObjective.Name)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, packetClientScoreboardObjective.Value)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, packetClientScoreboardObjective.Action)
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:13,代碼來源:packetClientScoreboardObjective17.go

示例7: Encode

func (this *packetClientJoinGameCodec17) Encode(writer io.Writer, encode packet.Packet) (err error) {
	packetClientJoinGame := encode.(*PacketClientJoinGame)
	err = packet.WriteInt32(writer, packetClientJoinGame.EntityId)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, packetClientJoinGame.Gamemode)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, packetClientJoinGame.Dimension)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, packetClientJoinGame.Difficulty)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, packetClientJoinGame.MaxPlayers)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, packetClientJoinGame.LevelType)
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:25,代碼來源:packetClientJoinGame17.go

示例8: Encode

func (this *packetServerClientSettingsCodec17) Encode(writer io.Writer, util []byte, encode packet.Packet) (err error) {
	packetServerClientSettings := encode.(*PacketServerClientSettings)
	err = packet.WriteString(writer, util, packetServerClientSettings.Locale)
	if err != nil {
		return
	}
	err = packet.WriteUint8(writer, util, packetServerClientSettings.ViewDistance)
	if err != nil {
		return
	}
	err = packet.WriteUint8(writer, util, packetServerClientSettings.ChatFlags)
	if err != nil {
		return
	}
	err = packet.WriteBool(writer, util, packetServerClientSettings.ChatColours)
	if err != nil {
		return
	}
	err = packet.WriteUint8(writer, util, packetServerClientSettings.difficulty17)
	if err != nil {
		return
	}
	err = packet.WriteBool(writer, util, packetServerClientSettings.ShowCape)
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:25,代碼來源:packetServerClientSettings17.go

示例9: Encode

func (this *packetClientJoinGameCodec) Encode(writer io.Writer, util []byte, encode packet.Packet) (err error) {
	packetClientJoinGame := encode.(*PacketClientJoinGame)
	err = packet.WriteInt32(writer, util, packetClientJoinGame.EntityId)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, util, packetClientJoinGame.Gamemode)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, util, packetClientJoinGame.Dimension)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, util, packetClientJoinGame.Difficulty)
	if err != nil {
		return
	}
	err = packet.WriteInt8(writer, util, packetClientJoinGame.MaxPlayers)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, util, packetClientJoinGame.LevelType)
	if err != nil {
		return
	}
	err = packet.WriteBool(writer, util, packetClientJoinGame.ReducedDebugInfo)
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:29,代碼來源:packetClientJoinGame.go

示例10: Encode

func (this *packetMessageEventCodec) Encode(writer io.Writer, encode packet.Packet) (err error) {
	packetMessageEvent := encode.(*PacketMessageEvent)
	err = packet.WriteString(writer, packetMessageEvent.Sender)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, packetMessageEvent.Channel)
	if err != nil {
		return
	}
	err = packet.WriteUint16(writer, uint16(len(packetMessageEvent.Payload)))
	if err != nil {
		return
	}
	_, err = writer.Write(packetMessageEvent.Payload)
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:17,代碼來源:packetMessageEvent.go

示例11: Encode

func (this *resultGetDetailsCodec) Encode(writer io.Writer, result Result) (err error) {
	resultGetDetails := result.(*ResultGetDetails)
	err = packet.WriteString(writer, resultGetDetails.Ip)
	if err != nil {
		return
	}
	err = packet.WriteUint16(writer, resultGetDetails.Port)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, resultGetDetails.Motd)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, resultGetDetails.Version)
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:17,代碼來源:requestGetDetails.go

示例12: Encode

func (this *RequestAsServerCodec) Encode(writer io.Writer, util []byte, request Request) (err error) {
	requestAsServer := request.(*RequestAsServer)
	err = packet.WriteString(writer, util, requestAsServer.Address)
	if err != nil {
		return
	}
	err = packet.WriteUint16(writer, util, requestAsServer.Port)
	return
}
開發者ID:Jumla,項目名稱:GoLilyPad,代碼行數:9,代碼來源:requestAsServer.go

示例13: Encode

func (this *packetServerPluginMessageCodec) Encode(writer io.Writer, encode packet.Packet) (err error) {
	packetServerPluginMessage := encode.(*PacketServerPluginMessage)
	err = packet.WriteString(writer, packetServerPluginMessage.Channel)
	if err != nil {
		return
	}
	_, err = writer.Write(packetServerPluginMessage.Data)
	return
}
開發者ID:0xNiklas,項目名稱:GoLilyPad,代碼行數:9,代碼來源:packetServerPluginMessage.go

示例14: Encode

func (this *requestNotifyPlayerCodec) Encode(writer io.Writer, util []byte, request Request) (err error) {
	requestNotifyPlayer := request.(*RequestNotifyPlayer)
	err = packet.WriteBool(writer, util, requestNotifyPlayer.Add)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, util, requestNotifyPlayer.Player)
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:9,代碼來源:requestNotifyPlayer.go

示例15: Encode

func (this *requestAsProxyCodec) Encode(writer io.Writer, util []byte, request Request) (err error) {
	requestAsProxy := request.(*RequestAsProxy)
	err = packet.WriteString(writer, util, requestAsProxy.Address)
	if err != nil {
		return
	}
	err = packet.WriteUint16(writer, util, requestAsProxy.Port)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, util, requestAsProxy.Motd)
	if err != nil {
		return
	}
	err = packet.WriteString(writer, util, requestAsProxy.Version)
	if err != nil {
		return
	}
	err = packet.WriteUint16(writer, util, requestAsProxy.MaxPlayers)
	return
}
開發者ID:LivousCraftNetwork,項目名稱:GoLilyPad,代碼行數:21,代碼來源:requestAsProxy.go


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