Node.js 使用节点ipc向特定客户端发送消息
我有一个电子应用程序,不同的客户端通过网络使用Node.js 使用节点ipc向特定客户端发送消息,node.js,electron,node-ipc,Node.js,Electron,Node Ipc,我有一个电子应用程序,不同的客户端通过网络使用节点ipc与服务器通信 只要客户机先连接到服务器,回答特定的客户机就没有问题。根据我在服务器上的文档: NodeIpc.serveNet( function () { NodeIpc.server.on( 'Client.message', function (data, socket) { NodeIpc.log('got a message from', (d
节点ipc
与服务器通信
只要客户机先连接到服务器,回答特定的客户机就没有问题。根据我在服务器上的文档:
NodeIpc.serveNet(
function () {
NodeIpc.server.on(
'Client.message',
function (data, socket) {
NodeIpc.log('got a message from', (data.id), (data.message));
NodeIpc.server.emit(
socket,
'ServerData',
{
message: 'have some initial cofiguration data'
}
);
);
NodeIpc.server.start();
}
关于我的客户:
NodeIPC.connectToNet(
'world',
function(){
NodeIPC.of.world.on(
'connect',
function(){
NodeIPC.log('## connected to world ##', NodeIPC.config.delay);
NodeIPC.of.world.emit(
'Client.message',
{
id : UniqueClientID,
message : 'Some information about myself'
}
);
});
});
这很好,但我不知道以后如何将一些附加信息推送到特定的客户机。尝试
NodeIpc.server.of['UniqueClientID'].emit(
'additional Data',
{
message: 'some more configuration'
}
)
});
及
不工作。
有人知道如何向特定客户发送消息吗?(当然,总是有可能广播该信息,让客户决定是否为他服务,但我更愿意直接与客户交谈)
NodeIpc.server.emit(
UniqueClientID,
'additional Data',
{
message: 'some more configuration'
});