the library didn't try to receive updates anymore when running a while
Closed this issue · 6 comments
FunkyYang commented
the library didn't try to receive updates anymore when running a while
FunkyYang commented
func (instance *tdlib) addClient(client *Client) {
instance.mu.Lock()
defer instance.mu.Unlock()
instance.clients[client.jsonClient.id] = client
instance.once.Do(func() {
go instance.receiver()
})
}
func (instance *tdlib) receiver() {
for {
resp, err := instance.receive(instance.timeout)
if err != nil {
continue
}
client, err := instance.getClient(resp.ClientId)
if err != nil {
log.Print(err)
continue
}
client.responses <- resp
}
}
I view code .it seems work
FunkyYang commented
func (instance *tdlib) receiver() {
for {
resp, err := instance.receive(instance.timeout)
if err != nil {
log.Print(err)
continue
}
log.Printf("clientId:%d", resp.ClientId)
client, err := instance.getClient(resp.ClientId)
if err != nil {
log.Print(err)
continue
}
client.responses <- resp
}
}
func (instance *tdlib) receive(timeout time.Duration) (*Response, error) {
result := C.td_receive(C.double(float64(timeout) / float64(time.Second)))
if result == nil {
return nil, errors.New("update receiving timeout")
}
data := []byte(C.GoString(result))
var resp Response
err := json.Unmarshal(data, &resp)
if err != nil {
return nil, err
}
resp.Data = data
return &resp, nil
}
zelenin commented
this is tdlib issue, not go-tdlib
FunkyYang commented
the listener.updates is fulled and blocking td_receive
purex121 commented
the listener.updates is fulled and blocking td_receive
did you find way to fix it i am facing the same issue