I am working on Chrome Extension with Native Host messaging. I am not able to use message text in my host application. Everything working fine from the establishing connection to get response in extension. I need to use Message text in my application for further use/execution in simple text datatype (string/char). I know message is in UTF8 encoded form i tried to decode but still getting problem, can any one help me out?
When i decode message chrome extension console show Error: "Error when communicating with the native messaging host." and if i use that message text after "cout" same error is there "Error when communicating with the native messaging host". Direct sending and receiving message works fine for me.
Code is something like this :
std::string mycode(std::string data){
data= data+"abc"; //changing text to any thing.
cout<< data;
anotherFunction(data);//killing processes using string data
}
int main(int argc, char* argv[])
{
std::cout.setf( std::ios_base::unitbuf );
while (true)
{
unsigned int ch, inMsgLen = 0, outMsgLen = 0;
std::string input = "", response = "";
std::cin.read((char*)&inMsgLen, 4);
if (inMsgLen == 0)
{
break;
}
else
{
for (int i=0; i < inMsgLen; i++)
{
ch = getchar();
input += ch;
}
}
response.append("{\"echo\":").append(input).append("}");
outMsgLen = response.length();
std::cout.write((char*)&outMsgLen, 4);
std::cout << response;
cout<< input;
//using "input" variable for further user
mycode(input);
}
return 0;
}