I have read docs, but still cannot realize. I have desktop application written in C and Chrome extension. I know how to receive this message in my chrome extension:
You can take a look here, this is an example python script which sends and receives messages to the extension: http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/nativeMessaging/host/native-messaging-example-host?revision=227442
As far as I understand it, in order to send the message you need to:
this is the C# code that did the job for me:
String str = "{\"text\": \"testmessage\"}";
Stream stdout = Console.OpenStandardOutput();
stdout.WriteByte((byte)str.Length);
stdout.WriteByte((byte)'\0');
stdout.WriteByte((byte)'\0');
stdout.WriteByte((byte)'\0');
Console.Write(str);
And the python code from the above link:
sys.stdout.write(struct.pack('I', len(message)))
sys.stdout.write(message)
sys.stdout.flush()
Interestingly it doesn't explicitly output the three \0 characters, but they seem to appear after outputting the struct.pack, not sure why...
Also note that you need to send the message in JSON format, otherwise it doesn't seem to work.