當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。