事件:'message'
🌐 Event: 'message'
message<Object> | <boolean> | <number> | <string> | <null> 一个解析后的 JSON 对象或可序列化的原始值。sendHandle<net.Server> | <net.Socket> 一个net.Server或net.Socket对象,或未定义。
如果 Node.js 进程是通过 IPC 通道启动的(参见 子进程 和 集群 文档),每当子进程接收到父进程使用 childprocess.send() 发送的消息时,就会触发 'message' 事件。
🌐 If the Node.js process is spawned with an IPC channel (see the Child Process
and Cluster documentation), the 'message' event is emitted whenever a
message sent by a parent process using childprocess.send() is received by
the child process.
消息会经过序列化和解析。最终得到的消息可能与最初发送的内容不完全相同。
🌐 The message goes through serialization and parsing. The resulting message might not be the same as what is originally sent.
如果在生成进程时将 serialization 选项设置为 advanced,message 参数可能包含 JSON 无法表示的数据。有关更多详细信息,请参见 child_process 的高级序列化。
🌐 If the serialization option was set to advanced used when spawning the
process, the message argument can contain data that JSON is not able
to represent.
See Advanced serialization for child_process for more details.