当前位置: 首页>>代码示例>>Golang>>正文


Golang network.IPacket类代码示例

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


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

示例1: ReadPacket

func (m *CreatureTurnMessage) ReadPacket(_packet pnet.IPacket) error {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.Direction = int(direction)

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:9,代码来源:creatureturnmessage.go

示例2: ReadPacket

func (m *DialogMessage) ReadPacket(_packet pnet.IPacket) error {
	answer, err := _packet.ReadUint32()
	if err != nil {
		return err
	}
	m.AnswerId = int(answer)

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:9,代码来源:dialogmessage.go

示例3: ReadPacket

func (m *QuestUpdateMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	if m.Id, err = _packet.ReadInt64(); err != nil {
		return err
	}

	if m.Removed, err = _packet.ReadBool(); err != nil {
		return err
	}

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:11,代码来源:questupdatemessage.go

示例4: ReadPacket

func (m *FriendUpdateMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	if m.Name, err = _packet.ReadString(); err != nil {
		return
	}
	removed, errRem := _packet.ReadUint8()
	if errRem != nil {
		return errRem
	}
	m.Removed = int(removed)

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:12,代码来源:friendupdatemessage.go

示例5: WritePacket

// WritePacket write the needed object data to a Packet and returns it
func (m *BattleEventMessage) WritePacket() pnet.IPacket {
	var packet pnet.IPacket = pnet.NewPacketExt(m.GetHeader())
	packet.AddUint32(m.EventType)

	switch m.EventType {
	case pnet.BATTLEEVENT_TEXT:
		packet = m.writeMessage(packet)
	case pnet.BATTLEEVENT_CHANGEPP:
		packet = m.writeChangePP(packet)
	case pnet.BATTLEEVENT_CHANGEHP:
		packet = m.writeChangeHP(packet)
	}

	return packet
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:16,代码来源:battleeventmessage.go

示例6: ReadPacket

// ReadPacket reads all data from a packet and puts it in the object
func (m *WalkMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	direction, err := _packet.ReadUint16()
	if err != nil {
		return
	}
	m.Direction = int(direction)

	sendMap, err := _packet.ReadUint16()
	if err != nil {
		return err
	}

	if sendMap == 1 {
		m.SendMap = true
	}

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:19,代码来源:walkmessage.go

示例7: writeChangePP

func (m *BattleEventMessage) writeChangePP(_packet pnet.IPacket) pnet.IPacket {
	_packet.AddUint32(m.PokemonId)
	_packet.AddUint32(m.MoveSlotId)
	_packet.AddUint8(m.NewPP)

	return _packet
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:7,代码来源:battleeventmessage.go

示例8: ReadPacket

func (m *ChatMessage) ReadPacket(_packet pnet.IPacket) (err error) {
	speaktype, err := _packet.ReadUint8()
	if err != nil {
		return
	}
	m.SpeakType = int(speaktype)

	channelId, err := _packet.ReadUint16()
	if err != nil {
		return
	}
	m.ChannelId = int(channelId)

	if m.Receiver, err = _packet.ReadString(); err != nil {
		return
	}
	if m.Text, err = _packet.ReadString(); err != nil {
		return
	}

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:22,代码来源:chatmessage.go

示例9: ReadPacket

// ReadPacket reads all data from a packet and puts it in the object
func (m *LoginMessage) ReadPacket(_packet pnet.IPacket) error {
	var err error
	if m.Username, err = _packet.ReadString(); err != nil {
		return err
	}
	if m.Password, err = _packet.ReadString(); err != nil {
		return err
	}
	clientVersion, err := _packet.ReadUint16()
	if err != nil {
		return err
	}
	m.ClientVersion = int(clientVersion)

	return nil
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:17,代码来源:loginmessage.go

示例10: writeMessage

func (m *BattleEventMessage) writeMessage(_packet pnet.IPacket) pnet.IPacket {
	_packet.AddString(m.Text)

	return _packet
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:5,代码来源:battleeventmessage.go

示例11: writeChangeHP

func (m *BattleEventMessage) writeChangeHP(_packet pnet.IPacket) pnet.IPacket {
	_packet.AddUint32(m.PokemonId)
	_packet.AddUint16(m.NewHP)

	return _packet
}
开发者ID:gasperko,项目名称:pokemon-universe,代码行数:6,代码来源:battleeventmessage.go


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