来自ipcMain的电子广播信息

时间:2017-05-23 05:52:04

标签: electron

我需要从主要的电子过程向所有渲染器进程广播消息。 ipcMain没有发送选项,只有通过event.sender.send()回复发件人的选项。

2 个答案:

答案 0 :(得分:2)

您正在寻找webContents API。来自帖子中的同一页文档:

  

也可以将消息从主进程发送到渲染器进程,有关详细信息,请参阅webContents.send。

以下是webContents

的文档

答案 1 :(得分:1)

您可以创建一个窗口数组,然后迭代它们并发送如下消息:

Caused by op u'Variable_2/read', defined at:
File "7.py", line 78, in <module>
b_conv2 = tf.Variable(tf.constant(0.1, shape=[63]))
File "/home/mcuee/.local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 197, in __init__
expected_shape=expected_shape)
File "/home/mcuee/.local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 316, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "/home/mcuee/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1338, in identity
result = _op_def_lib.apply_op("Identity", input=input, name=name)
File "/home/mcuee/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
op_def=op_def)
File "/home/mcuee/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/mcuee/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1228, in __init__
self._traceback = _extract_stack()

FailedPreconditionError (see above for traceback): Attempting to use   uninitialized value Variable_2
 [[Node: Variable_2/read = Identity[T=DT_FLOAT, _class=["loc:@Variable_2"], _device="/job:localhost/replica:0/task:0/cpu:0"](Variable_2)]]