事件:'message'


¥Event: 'message'

如果 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.