multi-instance fix

This commit is contained in:
Aleksandr Zelenin 2021-12-31 22:03:50 +03:00
parent d916d47121
commit e5d2ffd3f9
2 changed files with 26 additions and 8 deletions

View file

@ -39,7 +39,7 @@ func (jsonClient *JsonClient) Send(req Request) {
// shouldn't be called simultaneously from two different threads.
// Returned pointer will be deallocated by TDLib during next call to td_json_client_receive or td_json_client_execute
// in the same thread, so it can't be used after that.
func (jsonClient *JsonClient) Receive(timeout time.Duration) (*Response, error) {
func 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")
@ -54,10 +54,6 @@ func (jsonClient *JsonClient) Receive(timeout time.Duration) (*Response, error)
return nil, err
}
if resp.ClientId != jsonClient.id {
return nil, errors.New("wrong @client_id")
}
resp.Data = data
return &resp, nil