Вот мой код JavaScript:< /p>
Код: Выделить всё
Copiar código
const dados = {
nome: "João",
idade: 30
};
chrome.runtime.sendNativeMessage(
'com.my_company.my_application',
dados,
function(response) {
if (chrome.runtime.lastError) {
console.error("Error communicating with the native host:", chrome.runtime.lastError);
} else {
console.log('Response received: ', response);
}
}
);
Код: Выделить всё
using (var server = new NamedPipeServerStream("com.my_company.my_application", PipeDirection.InOut))
{
Console.WriteLine("Waiting for connection...");
server.WaitForConnection();
using (var reader = new StreamReader(server, Encoding.UTF8))
{
string message = reader.ReadToEnd();
Console.WriteLine("Message received: " + message);
}
}
Я знаю, что обмен данными происходит, потому что я получаю идентификатор расширения Chrome, но фактические данные не передаются.
Что может быть? быть причиной этой проблемы? Как правильно отправить данные из JavaScript в C#?
Я получаю message = {
nome: "João",
idade: 30
};
Подробнее здесь: https://stackoverflow.com/questions/792 ... -messaging
Мобильная версия