comunicação entre o aplicativo nativo e a extensão chrome

Eu tenho um aplicativo nativo escrito em c ++ e uma extensão chrome.

Estou me comunicando entre eles usando "mensagens nativas do Chrome".

Código nativo do aplicativo:

int main(int argc, char* argv[]) {
 unsigned int a, c, i, t=0;
 std::string inp;  do {
 inp="";
 t=0;
 // Sum the first 4 chars from stdin (the length of the message passed).
  for (i = 0; i <= 3; i++) {
    t += getchar();
  }

  // Loop getchar to pull in the message until we reach the total
  //  length provided.
  for (i=0; i < t; i++) {
    c = getchar();
    inp += c;
  }

// Collect the length of the message
unsigned int len = inp.length();
//// We need to send the 4 btyes of length information
std::cout << char(((len>>0) & 0xFF))
          << char(((len>>8) & 0xFF))
          << char(((len>>16) & 0xFF))
          << char(((len>>24) & 0xFF));
//// Now we can output our message
std::cout << inp <<std::endl;
flushall();
}while(cnt < 2 );
return 0;  }

Aqui estou lendo a mensagem enviada pelo chrome-extension no stdin. e enviando a mesma mensagem de volta escrevendo no stdout.

A extensão está usando PostMessage ()

Isso está funcionando ... MAS ..

Quando coloco meu programa sob loop while contínuo, o fluxo é executado apenas uma vez!

Ou seja, o port.postMessage ({'text': 'hello_1'}) é retornado como esperado, mas se eu fizer isso

port.postMessage ({'text': 'hello_2'}) ele não é exibido de volta.

Eu não consigo entender qual é o problema. Isso requer segmentação?

Por favor ajude!

Obrigado!

questionAnswers(3)

yourAnswerToTheQuestion