我需要在worker线程内向外部主机发送数据,如何将udp socket传递给worker
const WORKER = wx.createWorker('/worker/WorkerSender.js');
...
udp = wx.createUDPSocket();
...
WORKER.postMessage(
{
sock: udp,
data: frameBuffer
}
);
worker线程如下
worker.onMessage(function (res)
{
res.sock.send(
{
address: '192.168.1.8', //'192.168.137.1',
port: 22224,
message: res.data
});
});
报错说
thirdScriptError
worker uncaught third Error
TypeError
TypeError: s.sock.send is not a function.......... 's.sock.send' is undefined
不行的,worker 内无法处理 WebSocket