wechat.go 738 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package wechat
  2. import (
  3. "context"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/common/dice"
  6. "v2ray.com/core/common/serial"
  7. )
  8. type VideoChat struct {
  9. sn int
  10. }
  11. func (vc *VideoChat) Size() int {
  12. return 13
  13. }
  14. // Write implements io.Writer.
  15. func (vc *VideoChat) Write(b []byte) (int, error) {
  16. vc.sn++
  17. b = append(b[:0], 0xa1, 0x08)
  18. b = serial.IntToBytes(vc.sn, b)
  19. b = append(b, 0x10, 0x11, 0x18, 0x30, 0x22, 0x30)
  20. return 13, nil
  21. }
  22. // NewVideoChat returns a new VideoChat instance based on given config.
  23. func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
  24. return &VideoChat{
  25. sn: int(dice.RollUint16()),
  26. }, nil
  27. }
  28. func init() {
  29. common.Must(common.RegisterConfig((*VideoConfig)(nil), NewVideoChat))
  30. }