mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-21 08:34:22 +01:00
improved error handling in jsonrpc2 client
This commit is contained in:
@@ -317,7 +317,7 @@ func (s *SignalClient) Init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
go s.jsonRpc2Clients[number].ReceiveData() //receive messages in goroutine
|
go s.jsonRpc2Clients[number].ReceiveData(number) //receive messages in goroutine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -93,12 +93,12 @@ func (r *JsonRpc2Client) getRaw(command string, args interface{}) (string, error
|
|||||||
return string(resp.Result), nil
|
return string(resp.Result), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *JsonRpc2Client) ReceiveData() {
|
func (r *JsonRpc2Client) ReceiveData(number string) {
|
||||||
connbuf := bufio.NewReader(r.conn)
|
connbuf := bufio.NewReader(r.conn)
|
||||||
for {
|
for {
|
||||||
str, err := connbuf.ReadString('\n')
|
str, err := connbuf.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Couldn't read data: ", err.Error())
|
log.Error("Couldn't read data for number ", number, ": ", err.Error(), ". Is the number properly registered?")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//log.Info("Received data = ", str)
|
//log.Info("Received data = ", str)
|
||||||
|
|||||||
Reference in New Issue
Block a user