我創建了一個Firefox擴展和C#應用程序,我需要一個String
發送到我的分機進行一些工作如何使用C#應用程序將消息發送到Firefox擴展?
我需要通過像插座一個HTTP請求發送。我看了一下nsIServerSocket
和遇到問題連接到我的C#應用程序
火狐(擴展)代碼:
function startServer()
{
var listener =
{
onSocketAccepted : function(socket, transport)
{
input = clientSocket.openInputStream(0, 0, 0);
},
onStopListening : function(socket, status){}
};
var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]
.createInstance(Components.interfaces.nsIServerSocket);
serverSocket.init(9999,true,-1);
serverSocket.asyncListen(listener);
}
window.addEventListener("load", function() { startServer(); }, false);
C#(應用程序)代碼:
public void acceptClient()
{
TcpListener server = null;
Int32 port = 9999;
IPAddress localAddr = IPAddress.Parse("?");
// **no idea what IP address should come here**
server = new TcpListener(localAddr, port);
server.Start();
// Buffer for reading data
Byte[] bytes = new Byte[256];
// listening loop.
while (true)
{
Console.Write("Waiting for a connection... ");
TcpClient client = server.AcceptTcpClient();
Console.WriteLine("Event was fired!");
}
}
而現在,我有點堅持下去。