improved error handling in jsonrpc2 client

This commit is contained in:
Bernhard B
2021-10-10 18:42:39 +02:00
parent 0023ebaf83
commit 094e42059d
2 changed files with 3 additions and 3 deletions

View File

@@ -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

View File

@@ -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)