port.start()
开始在此 MessagePort
上接收消息。
当将此端口用作事件触发器时,一旦绑定了 'message'
监听器,则就会自动调用它。
此方法与 Web MessagePort
API 相同。
在 Node.js 中,只有在没有事件监听器时才用于忽略消息。
Node.js 在处理 .onmessage
方面也有分歧。
设置它会自动调用 .start()
,但取消设置它会让消息排队直到设置新的句柄或端口被丢弃。
Starts receiving messages on this MessagePort
. When using this port
as an event emitter, this will be called automatically once 'message'
listeners are attached.
This method exists for parity with the Web MessagePort
API. In Node.js,
it is only useful for ignoring messages when no event listener is present.
Node.js also diverges in its handling of .onmessage
. Setting it will
automatically call .start()
, but unsetting it will let messages queue up
until a new handler is set or the port is discarded.