import s from 'apigo.cc/gojs/service' import co from 'apigo.cc/gojs/console' function onStart() { co.info('task start') } let i = 0 function onRun() { let connCount = s.dataCount('wsTest') if (connCount > 0) { let conns = s.dataFetch('wsTest') for (let id in conns) { let conn = conns[id] try { conn.write(i++) } catch (e) { co.error(e) s.dataRemove('wsTest', id) } } } co.info('task run', connCount) } function onStop() { s.dataRemove('wsTest') co.info('task stop', s.dataCount('wsTest')) }