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