connection

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: 0BSD Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWSSURL

func BuildWSSURL(cdnHost string, roomID string, timezone string, language string, region string, compress bool, heartbeatInterval time.Duration) string

BuildWSSURL constructs the TikTok Live WebSocket URL for a given room. The timezone parameter should be an IANA timezone name (e.g. "Europe/London"). When compress is true, the server sends gzip-compressed frames; when false, uncompressed protobuf. heartbeatInterval feeds the heartbeat_duration param (ms); <= 0 means 10s.

func DecompressIfGzipped added in v0.1.4

func DecompressIfGzipped(data []byte) ([]byte, error)

DecompressIfGzipped checks for gzip magic bytes and decompresses if present.

func RunWebSocket

func RunWebSocket(ctx context.Context, wssURL string, cookieHeader string, userAgent string, roomID string, heartbeatInterval time.Duration, staleTimeout time.Duration, acceptLanguage string, proxy string, eventCh chan<- events.Event) error

RunWebSocket connects to the TikTok Live WSS endpoint and streams events. The userAgent parameter sets the User-Agent header for the WSS handshake. The cookieHeader is the full Cookie header value (e.g. "ttwid=xxx; sessionid=yyy"). Pass acceptLanguage for locale-aware header (e.g. "ro-RO,ro;q=0.9"). Empty = auto-detect. Pass proxy URL for HTTP CONNECT tunneling; empty falls back to env vars. heartbeatInterval <= 0 means the 10s default.

Types

type DeviceBlockedError

type DeviceBlockedError struct{}

DeviceBlockedError is returned when the WSS handshake responds with Handshake-Msg: DEVICE_BLOCKED, meaning the ttwid was flagged.

func (*DeviceBlockedError) Error

func (e *DeviceBlockedError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址