2017-01-03 16:46:22 -05:00
|
|
|
package wechat
|
|
|
|
|
|
|
|
import (
|
2017-01-12 16:47:10 -05:00
|
|
|
"context"
|
2018-11-02 10:47:58 -04:00
|
|
|
"encoding/binary"
|
2017-01-12 16:47:10 -05:00
|
|
|
|
2021-02-16 15:31:50 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v4/common"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/common/dice"
|
2017-01-03 16:46:22 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type VideoChat struct {
|
2018-11-02 10:47:58 -04:00
|
|
|
sn uint32
|
2017-01-03 16:46:22 -05:00
|
|
|
}
|
|
|
|
|
2018-04-02 14:00:50 -04:00
|
|
|
func (vc *VideoChat) Size() int32 {
|
2017-01-03 16:46:22 -05:00
|
|
|
return 13
|
|
|
|
}
|
|
|
|
|
2018-11-02 16:34:04 -04:00
|
|
|
// Serialize implements PacketHeader.
|
|
|
|
func (vc *VideoChat) Serialize(b []byte) {
|
2017-01-03 16:46:22 -05:00
|
|
|
vc.sn++
|
2018-11-02 10:47:58 -04:00
|
|
|
b[0] = 0xa1
|
|
|
|
b[1] = 0x08
|
|
|
|
binary.BigEndian.PutUint32(b[2:], vc.sn) // b[2:6]
|
|
|
|
b[6] = 0x00
|
|
|
|
b[7] = 0x10
|
|
|
|
b[8] = 0x11
|
|
|
|
b[9] = 0x18
|
|
|
|
b[10] = 0x30
|
|
|
|
b[11] = 0x22
|
|
|
|
b[12] = 0x30
|
2017-01-03 16:46:22 -05:00
|
|
|
}
|
|
|
|
|
2017-12-16 17:31:05 -05:00
|
|
|
// NewVideoChat returns a new VideoChat instance based on given config.
|
2017-01-12 16:47:10 -05:00
|
|
|
func NewVideoChat(ctx context.Context, config interface{}) (interface{}, error) {
|
2017-01-03 16:46:22 -05:00
|
|
|
return &VideoChat{
|
2018-11-02 10:47:58 -04:00
|
|
|
sn: uint32(dice.RollUint16()),
|
2017-01-12 16:47:10 -05:00
|
|
|
}, nil
|
2017-01-03 16:46:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2017-01-12 16:47:10 -05:00
|
|
|
common.Must(common.RegisterConfig((*VideoConfig)(nil), NewVideoChat))
|
2017-01-03 16:46:22 -05:00
|
|
|
}
|