github.com/Mrs4s/MiraiGo@v0.0.0-20240226124653-54bdd873e3fe/client/packet.go (about)

     1  package client
     2  
     3  import (
     4  	"github.com/Mrs4s/MiraiGo/client/internal/network"
     5  	"github.com/Mrs4s/MiraiGo/client/internal/oicq"
     6  )
     7  
     8  //go:noinline
     9  func (c *QQClient) buildOicqRequestPacket(uin int64, command uint16, body *oicq.TLV) []byte {
    10  	req := oicq.Message{
    11  		Uin:              uint32(uin),
    12  		Command:          command,
    13  		EncryptionMethod: oicq.EM_ECDH,
    14  		Body:             body.Marshal(),
    15  	}
    16  	return c.oicq.Marshal(&req)
    17  }
    18  
    19  //go:noinline
    20  func (c *QQClient) uniPacket(command string, body []byte) (uint16, []byte) {
    21  	seq := c.nextSeq()
    22  	req := network.Request{
    23  		Type:        network.RequestTypeSimple,
    24  		EncryptType: network.EncryptTypeD2Key,
    25  		Uin:         c.Uin,
    26  		SequenceID:  int32(seq),
    27  		CommandName: command,
    28  		Body:        body,
    29  	}
    30  	return seq, c.transport.PackPacket(&req)
    31  }
    32  
    33  //go:noinline
    34  func (c *QQClient) uniPacketWithSeq(seq uint16, command string, body []byte) []byte {
    35  	req := network.Request{
    36  		Type:        network.RequestTypeSimple,
    37  		EncryptType: network.EncryptTypeD2Key,
    38  		Uin:         c.Uin,
    39  		SequenceID:  int32(seq),
    40  		CommandName: command,
    41  		Body:        body,
    42  	}
    43  	return c.transport.PackPacket(&req)
    44  }