Documentation ¶
Index ¶
Constants ¶
const ( // DefaultVersion is a default version of the VK Long Poll API. DefaultVersion = 2 // DefaultWait is a waiting period. Maximum: 90. DefaultWait = 25 // DefaultMode is an additional answer options. DefaultMode = ReceiveAttachments )
const (
EventNewMessage = 4
)
Event codes.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Longpoll ¶
type Longpoll struct { Key string Server string Wait int64 Mode Mode Version int64 NeedPts int64 GroupID int64 // contains filtered or unexported fields }
Longpoll manages communication with VK User Long Poll API.
func NewWithOptions ¶
NewWithOptions initializes a new longpoll client with default values. It takes functors to modify values when creating it, like `NewWithOptions(WithMode(…))`.
func (*Longpoll) GetUpdatesStream ¶
GetUpdatesStream starts and returns a stream of updates.
func (*Longpoll) Poll ¶
Poll requests updates starting with the ts and returns a new updates and ts.
func (*Longpoll) UpdateServer ¶
UpdateServer updates the longpoll server and returns a new ts.
type NewMessage ¶
type NewMessage struct { ID int64 Flags int64 PeerID int64 Timestamp int64 Text string Attachments map[string]string RandomID int64 }
NewMessage represents the information an event EventNewMessage contains.
type Stream ¶
type Stream struct { TS int64 Updates <-chan *Update Errors <-chan error // contains filtered or unexported fields }
Stream represents a stream of events the VK User Longpoll API.
type Update ¶
type Update struct { Type int64 Data interface{} RawData json.RawMessage }
Update represents the information an event contains.
func (*Update) Unmarshal ¶
Unmarshal parses JSON-encoded update.RawData and stores the result in the struct value pointed to by outputStruct.
func (*Update) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.