-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.go
executable file
·39 lines (31 loc) · 1.24 KB
/
events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// AUTOGENERATED - DO NOT EDIT
package tdlib
type EventFunctions interface {
GetRawUpdatesChannel(capacity int) chan UpdateMsg
AddEventReceiver(msgInstance TdMessage, filterFunc EventFilterFunc, channelCapacity int) EventReceiver
}
// EventFilterFunc used to filter out unwanted messages in receiver channels
type EventFilterFunc func(msg *TdMessage) bool
// EventReceiver used to retreive updates from tdlib to user
type EventReceiver struct {
Instance TdMessage
Chan chan TdMessage
FilterFunc EventFilterFunc
}
// GetRawUpdatesChannel creates a general channel that fetches every update comming from tdlib
func (client *ClientImpl) GetRawUpdatesChannel(capacity int) chan UpdateMsg {
client.rawUpdates = make(chan UpdateMsg, capacity)
return client.rawUpdates
}
// AddEventReceiver adds a new receiver to be subscribed in receiver channels
func (client *ClientImpl) AddEventReceiver(msgInstance TdMessage, filterFunc EventFilterFunc, channelCapacity int) EventReceiver {
receiver := EventReceiver{
Instance: msgInstance,
Chan: make(chan TdMessage, channelCapacity),
FilterFunc: filterFunc,
}
client.receiverLock.Lock()
defer client.receiverLock.Unlock()
client.receivers = append(client.receivers, receiver)
return receiver
}