code: func (pc *ProtoClient) waitForData() {
  	for {
  		select {
  		case response := <-pc.Client.IncomingMsgChan:
  
  			inputMsg := dynamic.NewMessage(pc.expectedInputDescriptor)
  
  			msg, ok := pc.info.Commands[response.Route]
  			if ok {
  				inputMsg = dynamic.NewMessage(msg.outputMsgDescriptor)
  			} else {
  				pc.expectedInputDescriptor = nil
  			}
  
  			if response.Err {
  				errMsg := &protos.Error{}
  				err := proto.Unmarshal(response.Data, errMsg)
  				if err != nil {
  					logger.Log.Errorf("Erro decode error data: %s", string(response.Data))
  					continue
  				}
  				response.Data, err = json.Marshal(errMsg)
  				if err != nil {
  					logger.Log.Errorf("Erro encode error to json: %s", string(response.Data))
  					continue
  				}
  				pc.IncomingMsgChan <- response
  				continue
  			}
  
  			if inputMsg == nil {
  				logger.Log.Errorf("Not expected data: %s", string(response.Data))
  				continue
  			}
  
  			err := inputMsg.Unmarshal(response.Data)
  			if err != nil {
  				logger.Log.Errorf("Erro decode data: %s", string(response.Data))
  				continue
  			}
  
  			data, err2 := inputMsg.MarshalJSON()
  			if err2 != nil {
  				logger.Log.Errorf("Erro encode data to json: %s", string(response.Data))
  				continue
  			}
  
  			response.Data = data
  			pc.IncomingMsgChan <- response
  		case <-pc.closeChan:
  			return
  		}
  	}
  }
docs: // Wait for new messages from the server or the connection end. If the menssage
  // has a response.Route, it decodes based on it. If not, it will try to decode
  // the menssage using the last expected response.