1 | var worker = new Worker('dedicated.js'); |
1 | worker.onmessage = function (event) { ... }; |
1 2 3 4 5 6 | worker.postMessage({ operation: 'list_all_users', //ArrayBuffer object input: buffer, threshold: 0.8, }, [buffer]); |
1 2 3 4 5 6 7 | // 从端口接收数据 , 包括文本数据以及结构化数据 1. worker.port.onmessage = function (event) { define your logic here... }; // 向端口发送普通文本数据 2. worker.port.postMessage('put your message here … '); // 向端口发送结构化数据 3. worker.port.postMessage({ username: 'usertext'; live_city: ['data-one', 'data-two', 'data-three','data-four']}); |
1 2 3 4 5 6 7 8 9 | interface WorkerGlobalScope { readonly attribute WorkerGlobalScope self; readonly attribute WorkerLocation location; void close(); attribute Function onerror; }; WorkerGlobalScope implements WorkerUtils; WorkerGlobalScope implements EventTarget; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |