本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例10: writeMessage
func (m *BattleEventMessage) writeMessage(_packet pnet.IPacket) pnet.IPacket {
_packet.AddString(m.Text)
return _packet
}
示例11: writeChangeHP
func (m *BattleEventMessage) writeChangeHP(_packet pnet.IPacket) pnet.IPacket {
_packet.AddUint32(m.PokemonId)
_packet.AddUint16(m.NewHP)
return _packet
}