wechat.go 804 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package wechat
  2. import (
  3. "context"
  4. "encoding/binary"
  5. "github.com/v2fly/v2ray-core/v4/common"
  6. "github.com/v2fly/v2ray-core/v4/common/dice"
  7. )
  8. type VideoChat struct {
  9. sn uint32
  10. }
  11. func (vc *VideoChat) Size() int32 {
  12. return 13
  13. }
  14. // Serialize implements PacketHeader.
  15. func (vc *VideoChat) Serialize(b []byte) {
  16. vc.sn++
  17. b[0] = 0xa1
  18. b[1] = 0x08
  19. binary.BigEndian.PutUint32(b[2:], vc.sn) // b[2:6]
  20. b[6] = 0x00
  21. b[7] = 0x10
  22. b[8] = 0x11
  23. b[9] = 0x18
  24. b[10] = 0x30
  25. b[11] = 0x22
  26. b[12] = 0x30
  27. }
  28. // NewVideoChat returns a new VideoChat instance based on given config.
  29. func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
  30. return &VideoChat{
  31. sn: uint32(dice.RollUint16()),
  32. }, nil
  33. }
  34. func init() {
  35. common.Must(common.RegisterConfig((*VideoConfig)(nil), NewVideoChat))
  36. }