当前位置: 首页>>代码示例>>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;未经允许,请勿转载。